https://github.com/2dust/v2rayN/issues/6263
This commit is contained in:
2dust 2024-12-15 14:41:29 +08:00
parent 11db87f1e6
commit f2ec03c7ec
2 changed files with 5 additions and 5 deletions

View file

@ -56,13 +56,13 @@ public partial class App : Application
{ {
} }
private void MenuAddServerViaClipboardClick(object? sender, EventArgs e) private async void MenuAddServerViaClipboardClick(object? sender, EventArgs e)
{ {
if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) if (Application.Current?.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{ {
if (desktop.MainWindow != null) if (desktop.MainWindow != null)
{ {
var clipboardData = AvaUtils.GetClipboardData(desktop.MainWindow).Result; var clipboardData = await AvaUtils.GetClipboardData(desktop.MainWindow);
var service = Locator.Current.GetService<MainWindowViewModel>(); var service = Locator.Current.GetService<MainWindowViewModel>();
if (service != null) _ = service.AddServerViaClipboardAsync(clipboardData); if (service != null) _ = service.AddServerViaClipboardAsync(clipboardData);
} }

View file

@ -20,7 +20,7 @@ namespace v2rayN.Views
_config.GlobalHotkeys ??= new List<KeyEventItem>(); _config.GlobalHotkeys ??= new List<KeyEventItem>();
btnReset.Click += btnReset_Click; btnReset.Click += btnReset_Click;
btnSave.Click += btnSave_Click; btnSave.Click += btnSave_ClickAsync;
txtGlobalHotkey0.KeyDown += TxtGlobalHotkey_PreviewKeyDown; txtGlobalHotkey0.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
txtGlobalHotkey1.KeyDown += TxtGlobalHotkey_PreviewKeyDown; txtGlobalHotkey1.KeyDown += TxtGlobalHotkey_PreviewKeyDown;
@ -99,11 +99,11 @@ namespace v2rayN.Views
} }
} }
private void btnSave_Click(object sender, RoutedEventArgs e) private async void btnSave_ClickAsync(object sender, RoutedEventArgs e)
{ {
_config.GlobalHotkeys = _TextBoxKeyEventItem.Values.ToList(); _config.GlobalHotkeys = _TextBoxKeyEventItem.Values.ToList();
if (ConfigHandler.SaveConfig(_config).Result == 0) if (await ConfigHandler.SaveConfig(_config) == 0)
{ {
HotkeyHandler.Instance.ReLoad(); HotkeyHandler.Instance.ReLoad();
this.DialogResult = true; this.DialogResult = true;