mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add support for hiding dulplicated windows apps
This commit is contained in:
parent
1a54eed7ed
commit
ccf8d876ae
2 changed files with 29 additions and 0 deletions
|
|
@ -72,6 +72,8 @@ namespace Flow.Launcher.Plugin.Program
|
|||
private const string ExeUninstallerSuffix = ".exe";
|
||||
private const string InkUninstallerSuffix = ".lnk";
|
||||
|
||||
private const string WindowsAppPath = "c:\\program files\\windowsapps";
|
||||
|
||||
static Main()
|
||||
{
|
||||
}
|
||||
|
|
@ -90,11 +92,20 @@ namespace Flow.Launcher.Plugin.Program
|
|||
{
|
||||
try
|
||||
{
|
||||
// Collect all UWP Windows app directories
|
||||
var uwpsDirectories = _settings.HideDulplicatedWindowsApp ? _uwps
|
||||
.Where(uwp => !string.IsNullOrEmpty(uwp.Location)) // Exclude invalid paths
|
||||
.Where(uwp => uwp.Location.StartsWith(WindowsAppPath, StringComparison.OrdinalIgnoreCase)) // Keep system apps
|
||||
.Select(uwp => uwp.Location.TrimEnd('\\')) // Remove trailing slash
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.ToArray() : null;
|
||||
|
||||
return _win32s.Cast<IProgram>()
|
||||
.Concat(_uwps)
|
||||
.AsParallel()
|
||||
.WithCancellation(token)
|
||||
.Where(HideUninstallersFilter)
|
||||
.Where(p => HideDulplicatedWindowsAppFilter(p, uwpsDirectories))
|
||||
.Where(p => p.Enabled)
|
||||
.Select(p => p.Result(query.Search, Context.API))
|
||||
.Where(r => r?.Score > 0)
|
||||
|
|
@ -152,6 +163,23 @@ namespace Flow.Launcher.Plugin.Program
|
|||
return true;
|
||||
}
|
||||
|
||||
private static bool HideDulplicatedWindowsAppFilter(IProgram program, string[] uwpsDirectories)
|
||||
{
|
||||
if (uwpsDirectories == null || uwpsDirectories.Length == 0) return true;
|
||||
if (program is UWPApp) return true;
|
||||
|
||||
var location = program.Location.TrimEnd('\\'); // Ensure trailing slash
|
||||
if (string.IsNullOrEmpty(location))
|
||||
return true; // Keep if location is invalid
|
||||
|
||||
if (!location.StartsWith(WindowsAppPath, StringComparison.OrdinalIgnoreCase))
|
||||
return true; // Keep if not a Windows app
|
||||
|
||||
// Check if the any Win32 executable directory contains UWP Windows app location matches
|
||||
return !uwpsDirectories.Any(uwpDirectory =>
|
||||
location.StartsWith(uwpDirectory, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
public async Task InitAsync(PluginInitContext context)
|
||||
{
|
||||
Context = context;
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ namespace Flow.Launcher.Plugin.Program
|
|||
public bool EnableRegistrySource { get; set; } = true;
|
||||
public bool EnablePathSource { get; set; } = false;
|
||||
public bool EnableUWP { get; set; } = true;
|
||||
public bool HideDulplicatedWindowsApp { get; set; } = true;
|
||||
|
||||
internal const char SuffixSeparator = ';';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue