diff --git a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs index 2b3bd61b0..5232e46da 100644 --- a/Flow.Launcher.Core/Plugin/JsonPRCModel.cs +++ b/Flow.Launcher.Core/Plugin/JsonPRCModel.cs @@ -30,12 +30,8 @@ namespace Flow.Launcher.Core.Plugin public string Data { get; set; } } - public class JsonRPCModelBase - { - public int Id { get; set; } - } - public class JsonRPCResponseModel : JsonRPCModelBase + public class JsonRPCResponseModel { public string Result { get; set; } @@ -49,18 +45,20 @@ namespace Flow.Launcher.Core.Plugin public string DebugMessage { get; set; } } - - public class JsonRPCRequestModel : JsonRPCModelBase + + public class JsonRPCRequestModel { - [JsonPropertyName("method")] public string Method { get; set; } - [JsonPropertyName("parameters")] public object[] Parameters { get; set; } + private static readonly JsonSerializerOptions options = new() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase + }; public override string ToString() { - return JsonSerializer.Serialize(this); + return JsonSerializer.Serialize(this, options); } } @@ -77,7 +75,6 @@ namespace Flow.Launcher.Core.Plugin /// public class JsonRPCClientRequestModel : JsonRPCRequestModel { - [JsonPropertyName("dontHideAfterAction")] public bool DontHideAfterAction { get; set; } } diff --git a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs index 65f8fc608..431458881 100644 --- a/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs +++ b/Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs @@ -47,8 +47,10 @@ namespace Flow.Launcher.Core.Plugin } } - private static readonly JsonSerializerOptions _options = new() + private static readonly JsonSerializerOptions options = new() { + PropertyNameCaseInsensitive = true, + IgnoreNullValues = true, Converters = { new JsonObjectConverter() @@ -60,8 +62,10 @@ namespace Flow.Launcher.Core.Plugin if (output == Stream.Null) return null; var queryResponseModel = await - JsonSerializer.DeserializeAsync(output, _options); + JsonSerializer.DeserializeAsync(output, options); + await output.DisposeAsync(); + return ParseResults(queryResponseModel); } @@ -70,7 +74,7 @@ namespace Flow.Launcher.Core.Plugin if (string.IsNullOrEmpty(output)) return null; var queryResponseModel = - JsonSerializer.Deserialize(output, _options); + JsonSerializer.Deserialize(output, options); return ParseResults(queryResponseModel); } @@ -110,7 +114,7 @@ namespace Flow.Launcher.Core.Plugin return !result.JsonRPCAction.DontHideAfterAction; } - var jsonRpcRequestModel = JsonSerializer.Deserialize(actionResponse, _options); + var jsonRpcRequestModel = JsonSerializer.Deserialize(actionResponse, options); if (jsonRpcRequestModel?.Method?.StartsWith("Flow.Launcher.") ?? false) { diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index a2a009329..134c3c002 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -58,6 +58,22 @@ namespace Flow.Launcher.Core.Plugin API.SavePluginSettings(); } + public static async ValueTask DisposePluginsAsync() + { + foreach (var pluginPair in AllPlugins) + { + switch (pluginPair.Plugin) + { + case IDisposable disposable: + disposable.Dispose(); + break; + case IAsyncDisposable asyncDisposable: + await asyncDisposable.DisposeAsync(); + break; + } + } + } + public static async Task ReloadData() { await Task.WhenAll(AllPlugins.Select(plugin => plugin.Plugin switch diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 735103938..5fab812e6 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -11,6 +11,7 @@ using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.ViewModel; +using Application = System.Windows.Application; using Screen = System.Windows.Forms.Screen; using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip; using DataFormats = System.Windows.DataFormats; @@ -46,10 +47,13 @@ namespace Flow.Launcher InitializeComponent(); } - private void OnClosing(object sender, CancelEventArgs e) + private async void OnClosing(object sender, CancelEventArgs e) { _notifyIcon.Visible = false; _viewModel.Save(); + e.Cancel = true; + await PluginManager.DisposePluginsAsync(); + Application.Current.Shutdown(); } private void OnInitialized(object sender, EventArgs e) diff --git a/Flow.Launcher/Storage/UserSelectedRecord.cs b/Flow.Launcher/Storage/UserSelectedRecord.cs index 8d8956cfa..23d8c4faf 100644 --- a/Flow.Launcher/Storage/UserSelectedRecord.cs +++ b/Flow.Launcher/Storage/UserSelectedRecord.cs @@ -28,6 +28,11 @@ namespace Flow.Launcher.Storage private static int GenerateStaticHashCode(string s, int start = HASH_INITIAL) { + if (s == null) + { + return start; + } + unchecked { // skip the empty space @@ -101,4 +106,4 @@ namespace Flow.Launcher.Storage return selectedCount; } } -} +} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml index fe5afa317..52cd784ee 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/Languages/sk.xaml @@ -19,6 +19,8 @@ Aktualizácia pluginu Tento plugin má dostupnú aktualizáciu, chcete ju zobraziť? Tento plugin je už nainštalovaný + Stiahnutie manifestu pluginu zlyhalo + Skontrolujte, či sa môžete pripojiť na github.com. Táto chyba znamená, že pravdepodobne nemôžete pluginy inštalovať alebo aktualizovať. diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json index a0b84ac9a..255546686 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/plugin.json @@ -6,7 +6,7 @@ "Name": "Plugins Manager", "Description": "Management of installing, uninstalling or updating Flow Launcher plugins", "Author": "Jeremy Wu", - "Version": "1.8.2", + "Version": "1.8.3", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.PluginsManager.dll", diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs index d9ea3ad97..6b1f072f1 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs @@ -1,4 +1,5 @@ -using System.Windows; +using System; +using System.Windows; namespace Flow.Launcher.Plugin.Program { @@ -20,18 +21,21 @@ namespace Flow.Launcher.Plugin.Program private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { - if (string.IsNullOrEmpty(tbSuffixes.Text)) + var suffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator, StringSplitOptions.RemoveEmptyEntries); + + if (suffixes.Length == 0) { string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); MessageBox.Show(warning); return; } - _settings.ProgramSuffixes = tbSuffixes.Text.Split(Settings.SuffixSeperator); + _settings.ProgramSuffixes = suffixes; + string msg = context.API.GetTranslation("flowlauncher_plugin_program_update_file_suffixes"); MessageBox.Show(msg); DialogResult = true; } } -} +} \ No newline at end of file diff --git a/Plugins/Flow.Launcher.Plugin.Program/plugin.json b/Plugins/Flow.Launcher.Plugin.Program/plugin.json index fe7a3415d..a37075b0c 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/plugin.json +++ b/Plugins/Flow.Launcher.Plugin.Program/plugin.json @@ -4,7 +4,7 @@ "Name": "Program", "Description": "Search programs in Flow.Launcher", "Author": "qianlifeng", - "Version": "1.5.3", + "Version": "1.5.4", "Language": "csharp", "Website": "https://github.com/Flow-Launcher/Flow.Launcher", "ExecuteFileName": "Flow.Launcher.Plugin.Program.dll", diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml b/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml index e71eaf345..90eb19cc9 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Languages/sk.xaml @@ -1,6 +1,7 @@  + Otvoriť vyhľadávanie v: Nové okno Nová karta