Use Ioc.Default in initialize function

This commit is contained in:
Jack251970 2025-02-23 14:37:29 +08:00
parent e989b5ac28
commit 8496cfc819
2 changed files with 5 additions and 6 deletions

View file

@ -111,7 +111,7 @@ namespace Flow.Launcher
Current.MainWindow = window; Current.MainWindow = window;
Current.MainWindow.Title = Constant.FlowLauncher; Current.MainWindow.Title = Constant.FlowLauncher;
HotKeyMapper.Initialize(mainVM); HotKeyMapper.Initialize();
// main windows needs initialized before theme change because of blur settings // main windows needs initialized before theme change because of blur settings
// TODO: Clean ThemeManager.Instance in future // TODO: Clean ThemeManager.Instance in future

View file

@ -5,10 +5,9 @@ using NHotkey;
using NHotkey.Wpf; using NHotkey.Wpf;
using Flow.Launcher.Core.Resource; using Flow.Launcher.Core.Resource;
using Flow.Launcher.ViewModel; using Flow.Launcher.ViewModel;
using Flow.Launcher.Core;
using ChefKeys; using ChefKeys;
using System.Globalization;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using CommunityToolkit.Mvvm.DependencyInjection;
namespace Flow.Launcher.Helper; namespace Flow.Launcher.Helper;
@ -17,10 +16,10 @@ internal static class HotKeyMapper
private static Settings _settings; private static Settings _settings;
private static MainViewModel _mainViewModel; private static MainViewModel _mainViewModel;
internal static void Initialize(MainViewModel mainVM) internal static void Initialize()
{ {
_mainViewModel = mainVM; _mainViewModel = Ioc.Default.GetRequiredService<MainViewModel>();
_settings = _mainViewModel.Settings; _settings = Ioc.Default.GetService<Settings>();
SetHotkey(_settings.Hotkey, OnToggleHotkey); SetHotkey(_settings.Hotkey, OnToggleHotkey);
LoadCustomPluginHotkey(); LoadCustomPluginHotkey();