11using System ;
2- using System . Diagnostics ;
32using System . Diagnostics . CodeAnalysis ;
43using System . IO ;
54using System . Linq ;
65using System . Net ;
7- using System . Net . Http ;
86using System . Threading . Tasks ;
97using Avalonia ;
108using Avalonia . Controls ;
11- using Avalonia . Controls . Notifications ;
129using Avalonia . Media ;
1310using Avalonia . Media . Imaging ;
1411using Avalonia . ReactiveUI ;
2118using Core . Services . MQTT ;
2219using Core . Services . Onnx ;
2320using Core . Services . Plugin ;
24- using Core . Utils ;
2521using Core . ViewModel . Main ;
2622using Core . ViewModel . Pages ;
2723using Core . ViewModel . Pages . customScenario ;
@@ -53,16 +49,17 @@ internal class Program
5349 [ STAThread ]
5450 public static void Main ( string [ ] args )
5551 {
52+ ServiceManager . Services = ConfigureServices ( ) ;
5653 try
5754 {
5855 // RxApp.DefaultExceptionHandler = new MyCoolObservableExceptionHandler();
59- TaskScheduler . UnobservedTaskException += ( sender , eventArgs ) => { Logger . Error ( eventArgs . Exception , "错误" ) ; } ;
56+ TaskScheduler . UnobservedTaskException += ( _ , eventArgs ) => { Logger . Error ( eventArgs . Exception , "错误" ) ; } ;
6057
61- AppDomain . CurrentDomain . UnhandledException += ( sender , e ) =>
58+ AppDomain . CurrentDomain . UnhandledException += ( _ , e ) =>
6259 {
6360 Logger . Fatal ( ( Exception ) e . ExceptionObject , "错误" ) ;
6461 } ;
65- AppDomain . CurrentDomain . ProcessExit += ( sender , e ) =>
62+ AppDomain . CurrentDomain . ProcessExit += ( _ , _ ) =>
6663 {
6764 Logger . Information ( "程序退出" ) ;
6865 LogManager . Logger . Dispose ( ) ;
@@ -97,9 +94,6 @@ public static void Main(string[] args)
9794 Logger . Fatal ( e , "" ) ;
9895 Environment . Exit ( 0 ) ;
9996 }
100- finally
101- {
102- }
10397 }
10498
10599 [ MemberNotNull ]
@@ -139,7 +133,7 @@ private static IServiceProvider ConfigureServices()
139133 services . AddTransient < IExplorerContextMenuService , ExplorerContextMenuService > ( ) ;
140134 services . AddTransient < IExplorerContextMenuConfiger , ExplorerContextMenuConfiger > ( ) ;
141135 services . AddTransient < IFileLocksmith , FileLocksmithService > ( ) ;
142- services . AddTransient < IFileLocksmithWindow , FileLocksmithWindow > ( e =>
136+ services . AddTransient < IFileLocksmithWindow , FileLocksmithWindow > ( _ =>
143137 {
144138 return Dispatcher . UIThread . Invoke ( ( ( ) => new FileLocksmithWindow ( ) ) ) ;
145139 } ) ;
@@ -169,7 +163,7 @@ private static IServiceProvider ConfigureServices()
169163 services . AddKeyedSingleton < UserControl , CustomScenariosManagerPage > ( "CustomScenariosManagerPage" ,
170164 ( e , _ ) => new CustomScenariosManagerPage
171165 { DataContext = e . GetService < CustomScenariosManagerPageViewModel > ( ) } ) ;
172- services . AddSingleton < HotKeyManagerPageViewModel > ( e => new HotKeyManagerPageViewModel { } ) ;
166+ services . AddSingleton < HotKeyManagerPageViewModel > ( e => new HotKeyManagerPageViewModel ( ) ) ;
173167 services . AddKeyedSingleton < UserControl , HotKeyManagerPage > ( "HotKeyManagerPage" ,
174168 ( e , _ ) => new HotKeyManagerPage { DataContext = e . GetService < HotKeyManagerPageViewModel > ( ) } ) ;
175169 services . AddTransient < PluginManagerPageViewModel > ( e => new PluginManagerPageViewModel { IsActive = true } ) ;
@@ -234,9 +228,6 @@ private static async Task CheckUpdates()
234228 public static void OnStartup ( string [ ] arg )
235229 {
236230 Logger . Information ( "启动" ) ;
237-
238- ServiceManager . Services = ConfigureServices ( ) ;
239-
240231 CheckAndDeleteLogFiles ( ) ;
241232 ServiceManager . Services . GetService < IToastService > ( ) ! . Init ( ) ;
242233
@@ -246,16 +237,13 @@ public static void OnStartup(string[] arg)
246237 await Task . Delay ( TimeSpan . FromMinutes ( 30 ) ) ;
247238 } ) ) ;
248239
249- Logger . Information ( "MQTT初始化完成" ) ;
240+
250241 HotKeyManager . Init ( ) ;
251242 Logger . Debug ( "注册热键管理器完成" ) ;
252243 ConfigManger . Init ( ) ;
253244 Logger . Information ( "配置文件初始化完成" ) ;
254245 if ( ConfigManger . Config . mouseCapture ) HotKeyManager . HotKetImpl . StartHook ( ) ;
255246
256- // If we are the server, we might need to process the local args now that services are ready
257- // But StartupArgumentManager.Parse(arg) result was already used in Init if we connected to another instance.
258- // Since we are here, we are the only instance. We should process args locally.
259247 MqttManager . ProcessLocalArgs ( arg ) . GetAwaiter ( ) . GetResult ( ) ;
260248
261249 if ( ServiceManager . Services . GetService < IExplorerContextMenuService > ( ) ! . RegisterAsync ( )
@@ -268,9 +256,6 @@ public static void OnStartup(string[] arg)
268256 {
269257 Logger . Warning ( "资源管理器右键菜单注册失败" ) ;
270258 }
271-
272-
273-
274259 switch ( ConfigManger . Config . themeChoice )
275260 {
276261 case ThemeEnum . 跟随系统 :
0 commit comments