Fix build issue & Improve code quality

This commit is contained in:
Jack251970 2025-04-05 23:01:09 +08:00
parent c8a9e5e947
commit 9e8a950580

View file

@ -1,7 +1,5 @@
using System; using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Text; using System.Text;
using JetBrains.Annotations;
using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Infrastructure.UserSettings;
using ToolGood.Words.Pinyin; using ToolGood.Words.Pinyin;
using System.Collections.Generic; using System.Collections.Generic;
@ -15,11 +13,11 @@ namespace Flow.Launcher.Infrastructure
private readonly ConcurrentDictionary<string, (string translation, TranslationMapping map)> _pinyinCache = private readonly ConcurrentDictionary<string, (string translation, TranslationMapping map)> _pinyinCache =
new(); new();
private Settings _settings; private readonly Settings _settings;
public void Initialize([NotNull] Settings settings) public PinyinAlphabet()
{ {
_settings = settings ?? throw new ArgumentNullException(nameof(settings)); _settings = Ioc.Default.GetRequiredService<Settings>();
} }
public bool ShouldTranslate(string stringToTranslate) public bool ShouldTranslate(string stringToTranslate)
@ -109,16 +107,6 @@ namespace Flow.Launcher.Infrastructure
{"Sh", "u"}, {"Sh", "u"},
{"Zh", "v"} {"Zh", "v"}
}); });
public PinyinAlphabet()
{
Initialize(Ioc.Default.GetRequiredService<Settings>());
}
private void Initialize([NotNull] Settings settings)
{
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
}
private static readonly ReadOnlyDictionary<string, string> second = new(new Dictionary<string, string>() private static readonly ReadOnlyDictionary<string, string> second = new(new Dictionary<string, string>()
{ {
@ -200,6 +188,7 @@ namespace Flow.Launcher.Infrastructure
return doublePin.ToString(); return doublePin.ToString();
} }
#endregion #endregion
} }
} }