Skip to content

Commit

Permalink
优化 搜索窗口加载逻辑,异步执行应用重载与状态检查
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Feb 25, 2025
1 parent 9968ba5 commit 2e4e895
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions Core/ViewModel/SearchWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ public partial class SearchWindowViewModel : ObservableRecipient

public SearchWindowViewModel()
{
ReloadApps(false);
LoadLast();

Task.Run((() =>
{
ReloadApps(false);
LoadLast();
}));
}

public void AddCollection(string search)
Expand All @@ -80,27 +84,14 @@ public void ReloadApps(bool logging = false)
{
if (_reloading) return;


_reloading = true;
CheckEverything();
ServiceManager.Services.GetService<IAppToolService>()!.DelNullFile(_collection);
ServiceManager.Services.GetService<IAppToolService>()!.GetAllApps(_collection, logging,
ConfigManger.Config.useEverything);

if (ConfigManger.Config.useEverything && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Log.Debug("everything检测");


var service = ServiceManager.Services.GetService<IEverythingService>()!;
EverythingIsOk = service.IsRun();

if (!EverythingIsOk.Value)
ServiceManager.Services.GetService<IAppToolService>()!.AutoStartEverything(_collection, () =>
{
Thread.Sleep(1500);
var everythingService = ServiceManager.Services.GetService<IEverythingService>()!;
EverythingIsOk = everythingService.IsRun();
});
}


foreach (var scenario in CustomScenarioManger.CustomScenarios)
{
Expand Down Expand Up @@ -131,6 +122,26 @@ public void ReloadApps(bool logging = false)
_reloading = false;
}

private void CheckEverything()
{
if (ConfigManger.Config.useEverything && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
Log.Debug("everything检测");


var service = ServiceManager.Services.GetService<IEverythingService>()!;
EverythingIsOk = service.IsRun();

if (!EverythingIsOk.Value)
ServiceManager.Services.GetService<IAppToolService>()!.AutoStartEverything(_collection, () =>
{
Thread.Sleep(1500);
var everythingService = ServiceManager.Services.GetService<IEverythingService>()!;
EverythingIsOk = everythingService.IsRun();
});
}
}


public void CheckClipboard()
{
Expand Down

0 comments on commit 2e4e895

Please sign in to comment.