Code clean
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release Linux / rpm (push) Blocked by required conditions
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run

This commit is contained in:
2dust 2025-10-31 20:25:54 +08:00
parent 1b5069a933
commit d727ff40bb
16 changed files with 57 additions and 57 deletions

View file

@ -17,13 +17,13 @@ global using Avalonia.Markup.Xaml;
global using Avalonia.Media; global using Avalonia.Media;
global using Avalonia.Media.Imaging; global using Avalonia.Media.Imaging;
global using Avalonia.Platform; global using Avalonia.Platform;
global using ReactiveUI.Avalonia;
global using Avalonia.Styling; global using Avalonia.Styling;
global using Avalonia.Threading; global using Avalonia.Threading;
global using ReactiveUI;
global using ReactiveUI.Fody.Helpers;
global using DynamicData; global using DynamicData;
global using MsBox.Avalonia.Enums; global using MsBox.Avalonia.Enums;
global using ReactiveUI;
global using ReactiveUI.Avalonia;
global using ReactiveUI.Fody.Helpers;
global using ServiceLib; global using ServiceLib;
global using ServiceLib.Base; global using ServiceLib.Base;
global using ServiceLib.Common; global using ServiceLib.Common;

View file

@ -13,8 +13,8 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
lstChild.SelectionChanged += LstChild_SelectionChanged; lstChild.SelectionChanged += LstChild_SelectionChanged;
ViewModel = new AddGroupServerViewModel(profileItem, UpdateViewHandler); ViewModel = new AddGroupServerViewModel(profileItem, UpdateViewHandler);
@ -32,11 +32,11 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
switch (profileItem.ConfigType) switch (profileItem.ConfigType)
{ {
case EConfigType.PolicyGroup: case EConfigType.PolicyGroup:
this.Title = ResUI.TbConfigTypePolicyGroup; Title = ResUI.TbConfigTypePolicyGroup;
break; break;
case EConfigType.ProxyChain: case EConfigType.ProxyChain:
this.Title = ResUI.TbConfigTypeProxyChain; Title = ResUI.TbConfigTypeProxyChain;
gridPolicyGroup.IsVisible = false; gridPolicyGroup.IsVisible = false;
break; break;
} }
@ -64,7 +64,7 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
menuSelectAllChild.Click += (s, e) => lstChild.SelectAll(); menuSelectAllChild.Click += (s, e) => lstChild.SelectAll();
// Keyboard shortcuts when focus is within grid // Keyboard shortcuts when focus is within grid
this.AddHandler(KeyDownEvent, AddGroupServerWindow_KeyDown, RoutingStrategies.Tunnel); AddHandler(KeyDownEvent, AddGroupServerWindow_KeyDown, RoutingStrategies.Tunnel);
lstChild.LoadingRow += LstChild_LoadingRow; lstChild.LoadingRow += LstChild_LoadingRow;
} }
@ -78,7 +78,7 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -14,8 +14,8 @@ public partial class AddServer2Window : WindowBase<AddServer2ViewModel>
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
ViewModel = new AddServer2ViewModel(profileItem, UpdateViewHandler); ViewModel = new AddServer2ViewModel(profileItem, UpdateViewHandler);
cmbCoreType.ItemsSource = Utils.GetEnumNames<ECoreType>().Where(t => t != ECoreType.v2rayN.ToString()).ToList().AppendEmpty(); cmbCoreType.ItemsSource = Utils.GetEnumNames<ECoreType>().Where(t => t != ECoreType.v2rayN.ToString()).ToList().AppendEmpty();
@ -39,7 +39,7 @@ public partial class AddServer2Window : WindowBase<AddServer2ViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
case EViewAction.BrowseServer: case EViewAction.BrowseServer:

View file

@ -13,8 +13,8 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged; cmbNetwork.SelectionChanged += CmbNetwork_SelectionChanged;
cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged; cmbStreamSecurity.SelectionChanged += CmbStreamSecurity_SelectionChanged;
btnGUID.Click += btnGUID_Click; btnGUID.Click += btnGUID_Click;
@ -196,7 +196,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
}); });
this.Title = $"{profileItem.ConfigType}"; Title = $"{profileItem.ConfigType}";
} }
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj) private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
@ -204,7 +204,7 @@ public partial class AddServerWindow : WindowBase<AddServerViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -7,7 +7,7 @@ public partial class ClashProxiesView : ReactiveUserControl<ClashProxiesViewMode
InitializeComponent(); InitializeComponent();
ViewModel = new ClashProxiesViewModel(UpdateViewHandler); ViewModel = new ClashProxiesViewModel(UpdateViewHandler);
lstProxyDetails.DoubleTapped += LstProxyDetails_DoubleTapped; lstProxyDetails.DoubleTapped += LstProxyDetails_DoubleTapped;
this.KeyDown += ClashProxiesView_KeyDown; KeyDown += ClashProxiesView_KeyDown;
this.WhenActivated(disposables => this.WhenActivated(disposables =>
{ {

View file

@ -12,7 +12,7 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
_config = AppManager.Instance.Config; _config = AppManager.Instance.Config;
Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
ViewModel = new DNSSettingViewModel(UpdateViewHandler); ViewModel = new DNSSettingViewModel(UpdateViewHandler);
cmbRayFreedomDNSStrategy.ItemsSource = Global.DomainStrategy4Freedoms; cmbRayFreedomDNSStrategy.ItemsSource = Global.DomainStrategy4Freedoms;
@ -77,7 +77,7 @@ public partial class DNSSettingWindow : WindowBase<DNSSettingViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -12,7 +12,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
_config = AppManager.Instance.Config; _config = AppManager.Instance.Config;
Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler); ViewModel = new FullConfigTemplateViewModel(UpdateViewHandler);
this.WhenActivated(disposables => this.WhenActivated(disposables =>
@ -36,7 +36,7 @@ public partial class FullConfigTemplateWindow : WindowBase<FullConfigTemplateVie
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -17,8 +17,8 @@ public partial class GlobalHotkeySettingWindow : WindowBase<GlobalHotkeySettingV
HotkeyManager.Instance.IsPause = true; HotkeyManager.Instance.IsPause = true;
Loaded += Window_Loaded; Loaded += Window_Loaded;
this.Closing += (s, e) => HotkeyManager.Instance.IsPause = false; Closing += (s, e) => HotkeyManager.Instance.IsPause = false;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
this.WhenActivated(disposables => this.WhenActivated(disposables =>
{ {
@ -34,7 +34,7 @@ public partial class GlobalHotkeySettingWindow : WindowBase<GlobalHotkeySettingV
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -21,7 +21,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
_config = AppManager.Instance.Config; _config = AppManager.Instance.Config;
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight }; _manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight };
this.KeyDown += MainWindow_KeyDown; KeyDown += MainWindow_KeyDown;
menuSettingsSetUWP.Click += menuSettingsSetUWP_Click; menuSettingsSetUWP.Click += menuSettingsSetUWP_Click;
menuPromotion.Click += menuPromotion_Click; menuPromotion.Click += menuPromotion_Click;
menuCheckUpdate.Click += MenuCheckUpdate_Click; menuCheckUpdate.Click += MenuCheckUpdate_Click;
@ -153,14 +153,14 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
if (Utils.IsWindows()) if (Utils.IsWindows())
{ {
this.Title = $"{Utils.GetVersion()} - {(Utils.IsAdministrator() ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}"; Title = $"{Utils.GetVersion()} - {(Utils.IsAdministrator() ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
ThreadPool.RegisterWaitForSingleObject(Program.ProgramStarted, OnProgramStarted, null, -1, false); ThreadPool.RegisterWaitForSingleObject(Program.ProgramStarted, OnProgramStarted, null, -1, false);
HotkeyManager.Instance.Init(_config, OnHotkeyHandler); HotkeyManager.Instance.Init(_config, OnHotkeyHandler);
} }
else else
{ {
this.Title = $"{Utils.GetVersion()}"; Title = $"{Utils.GetVersion()}";
menuRebootAsAdmin.IsVisible = false; menuRebootAsAdmin.IsVisible = false;
menuSettingsSetUWP.IsVisible = false; menuSettingsSetUWP.IsVisible = false;
@ -170,7 +170,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
if (_config.UiItem.AutoHideStartup && Utils.IsWindows()) if (_config.UiItem.AutoHideStartup && Utils.IsWindows())
{ {
this.WindowState = WindowState.Minimized; WindowState = WindowState.Minimized;
} }
AddHelpMenuItem(); AddHelpMenuItem();
@ -407,27 +407,27 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
: !_config.UiItem.ShowInTaskbar); : !_config.UiItem.ShowInTaskbar);
if (bl) if (bl)
{ {
this.Show(); Show();
if (this.WindowState == WindowState.Minimized) if (WindowState == WindowState.Minimized)
{ {
this.WindowState = WindowState.Normal; WindowState = WindowState.Normal;
} }
this.Activate(); Activate();
this.Focus(); Focus();
} }
else else
{ {
if (Utils.IsLinux() && _config.UiItem.Hide2TrayWhenClose == false) if (Utils.IsLinux() && _config.UiItem.Hide2TrayWhenClose == false)
{ {
this.WindowState = WindowState.Minimized; WindowState = WindowState.Minimized;
return; return;
} }
foreach (var ownedWindow in this.OwnedWindows) foreach (var ownedWindow in OwnedWindows)
{ {
ownedWindow.Close(); ownedWindow.Close();
} }
this.Hide(); Hide();
} }
_config.UiItem.ShowInTaskbar = bl; _config.UiItem.ShowInTaskbar = bl;

View file

@ -11,7 +11,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
InitializeComponent(); InitializeComponent();
Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
_config = AppManager.Instance.Config; _config = AppManager.Instance.Config;
ViewModel = new OptionSettingViewModel(UpdateViewHandler); ViewModel = new OptionSettingViewModel(UpdateViewHandler);
@ -153,7 +153,7 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
case EViewAction.InitSettingFont: case EViewAction.InitSettingFont:

View file

@ -13,8 +13,8 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
clbProtocol.SelectionChanged += ClbProtocol_SelectionChanged; clbProtocol.SelectionChanged += ClbProtocol_SelectionChanged;
clbInboundTag.SelectionChanged += ClbInboundTag_SelectionChanged; clbInboundTag.SelectionChanged += ClbInboundTag_SelectionChanged;
@ -61,7 +61,7 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -14,9 +14,9 @@ public partial class RoutingRuleSettingWindow : WindowBase<RoutingRuleSettingVie
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
this.KeyDown += RoutingRuleSettingWindow_KeyDown; KeyDown += RoutingRuleSettingWindow_KeyDown;
lstRules.SelectionChanged += lstRules_SelectionChanged; lstRules.SelectionChanged += lstRules_SelectionChanged;
lstRules.DoubleTapped += LstRules_DoubleTapped; lstRules.DoubleTapped += LstRules_DoubleTapped;
menuRuleSelectAll.Click += menuRuleSelectAll_Click; menuRuleSelectAll.Click += menuRuleSelectAll_Click;
@ -64,7 +64,7 @@ public partial class RoutingRuleSettingWindow : WindowBase<RoutingRuleSettingVie
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
case EViewAction.ShowYesNo: case EViewAction.ShowYesNo:

View file

@ -12,9 +12,9 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
InitializeComponent(); InitializeComponent();
Loaded += Window_Loaded; Loaded += Window_Loaded;
this.Closing += RoutingSettingWindow_Closing; Closing += RoutingSettingWindow_Closing;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
this.KeyDown += RoutingSettingWindow_KeyDown; KeyDown += RoutingSettingWindow_KeyDown;
lstRoutings.SelectionChanged += lstRoutings_SelectionChanged; lstRoutings.SelectionChanged += lstRoutings_SelectionChanged;
lstRoutings.DoubleTapped += LstRoutings_DoubleTapped; lstRoutings.DoubleTapped += LstRoutings_DoubleTapped;
menuRoutingAdvancedSelectAll.Click += menuRoutingAdvancedSelectAll_Click; menuRoutingAdvancedSelectAll.Click += menuRoutingAdvancedSelectAll_Click;
@ -48,7 +48,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
case EViewAction.ShowYesNo: case EViewAction.ShowYesNo:
@ -116,7 +116,7 @@ public partial class RoutingSettingWindow : WindowBase<RoutingSettingViewModel>
private void btnCancel_Click(object? sender, RoutedEventArgs e) private void btnCancel_Click(object? sender, RoutedEventArgs e)
{ {
_manualClose = true; _manualClose = true;
this.Close(ViewModel?.IsModified); Close(ViewModel?.IsModified);
} }
private void RoutingSettingWindow_Closing(object? sender, WindowClosingEventArgs e) private void RoutingSettingWindow_Closing(object? sender, WindowClosingEventArgs e)

View file

@ -14,7 +14,7 @@ public partial class SubEditWindow : WindowBase<SubEditViewModel>
InitializeComponent(); InitializeComponent();
Loaded += Window_Loaded; Loaded += Window_Loaded;
btnCancel.Click += (s, e) => this.Close(); btnCancel.Click += (s, e) => Close();
ViewModel = new SubEditViewModel(subItem, UpdateViewHandler); ViewModel = new SubEditViewModel(subItem, UpdateViewHandler);
@ -45,7 +45,7 @@ public partial class SubEditWindow : WindowBase<SubEditViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(true); Close(true);
break; break;
} }
return await Task.FromResult(true); return await Task.FromResult(true);

View file

@ -14,8 +14,8 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
menuClose.Click += menuClose_Click; menuClose.Click += menuClose_Click;
Loaded += Window_Loaded; Loaded += Window_Loaded;
this.Closing += SubSettingWindow_Closing; Closing += SubSettingWindow_Closing;
this.KeyDown += SubSettingWindow_KeyDown; KeyDown += SubSettingWindow_KeyDown;
ViewModel = new SubSettingViewModel(UpdateViewHandler); ViewModel = new SubSettingViewModel(UpdateViewHandler);
lstSubscription.DoubleTapped += LstSubscription_DoubleTapped; lstSubscription.DoubleTapped += LstSubscription_DoubleTapped;
lstSubscription.SelectionChanged += LstSubscription_SelectionChanged; lstSubscription.SelectionChanged += LstSubscription_SelectionChanged;
@ -37,7 +37,7 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
switch (action) switch (action)
{ {
case EViewAction.CloseWindow: case EViewAction.CloseWindow:
this.Close(); Close();
break; break;
case EViewAction.ShowYesNo: case EViewAction.ShowYesNo:
@ -89,7 +89,7 @@ public partial class SubSettingWindow : WindowBase<SubSettingViewModel>
private void menuClose_Click(object? sender, RoutedEventArgs e) private void menuClose_Click(object? sender, RoutedEventArgs e)
{ {
_manualClose = true; _manualClose = true;
this.Close(ViewModel?.IsModified); Close(ViewModel?.IsModified);
} }
private void SubSettingWindow_Closing(object? sender, WindowClosingEventArgs e) private void SubSettingWindow_Closing(object? sender, WindowClosingEventArgs e)

View file

@ -9,7 +9,7 @@ public partial class SudoPasswordInputView : UserControl
{ {
InitializeComponent(); InitializeComponent();
this.Loaded += (s, e) => txtPassword.Focus(); Loaded += (s, e) => txtPassword.Focus();
btnSave.Click += async (_, _) => await SavePasswordAsync(); btnSave.Click += async (_, _) => await SavePasswordAsync();