mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 20:57:22 +02:00
@@ -30,24 +30,24 @@ namespace Wox.Plugin.Program
|
|||||||
{
|
{
|
||||||
|
|
||||||
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
var fuzzyMather = FuzzyMatcher.Create(query.Search);
|
||||||
List<Program> returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
|
var results = programs.Where(o => MatchProgram(o, fuzzyMather)).
|
||||||
returnList.ForEach(ScoreFilter);
|
Select(ScoreFilter).
|
||||||
returnList = returnList.OrderByDescending(o => o.Score).ToList();
|
OrderByDescending(o => o.Score)
|
||||||
|
.Select(c => new Result()
|
||||||
return returnList.Select(c => new Result()
|
{
|
||||||
{
|
Title = c.Title,
|
||||||
Title = c.Title,
|
SubTitle = c.ExecutePath,
|
||||||
SubTitle = c.ExecutePath,
|
IcoPath = c.IcoPath,
|
||||||
IcoPath = c.IcoPath,
|
Score = c.Score,
|
||||||
Score = c.Score,
|
ContextData = c,
|
||||||
ContextData = c,
|
Action = (e) =>
|
||||||
Action = (e) =>
|
{
|
||||||
{
|
context.API.HideApp();
|
||||||
context.API.HideApp();
|
context.API.ShellRun(c.ExecutePath);
|
||||||
context.API.ShellRun(c.ExecutePath);
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
}).ToList();
|
||||||
}).ToList();
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string ResolveShortcut(string filePath)
|
static string ResolveShortcut(string filePath)
|
||||||
@@ -60,12 +60,10 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
private bool MatchProgram(Program program, FuzzyMatcher matcher)
|
private bool MatchProgram(Program program, FuzzyMatcher matcher)
|
||||||
{
|
{
|
||||||
if ((program.Score = matcher.Evaluate(program.Title).Score) > 0) return true;
|
var scores = new List<string> { program.Title, program.PinyinTitle, program.AbbrTitle, program.ExecuteName };
|
||||||
if ((program.Score = matcher.Evaluate(program.PinyinTitle).Score) > 0) return true;
|
program.Score = scores.Select(s => matcher.Evaluate(s ?? string.Empty).Score).Max();
|
||||||
if (program.AbbrTitle != null && (program.Score = matcher.Evaluate(program.AbbrTitle).Score) > 0) return true;
|
if (program.Score > 0) return true;
|
||||||
if (program.ExecuteName != null && (program.Score = matcher.Evaluate(program.ExecuteName).Score) > 0) return true;
|
else return false;
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(PluginInitContext context)
|
public void Init(PluginInitContext context)
|
||||||
@@ -161,7 +159,7 @@ namespace Wox.Plugin.Program
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ScoreFilter(Program p)
|
private Program ScoreFilter(Program p)
|
||||||
{
|
{
|
||||||
p.Score += p.Source.BonusPoints;
|
p.Score += p.Source.BonusPoints;
|
||||||
|
|
||||||
@@ -173,6 +171,7 @@ namespace Wox.Plugin.Program
|
|||||||
|
|
||||||
if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall"))
|
if (p.Title.Contains("卸载") || p.Title.ToLower().Contains("uninstall"))
|
||||||
p.Score -= 20;
|
p.Score -= 20;
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region ISettingProvider Members
|
#region ISettingProvider Members
|
||||||
|
|||||||
@@ -47,7 +47,10 @@ namespace Wox.Plugin
|
|||||||
Result r = obj as Result;
|
Result r = obj as Result;
|
||||||
if (r != null)
|
if (r != null)
|
||||||
{
|
{
|
||||||
return string.Equals(r.Title, Title) && string.Equals(r.SubTitle, SubTitle);
|
var equality = string.Equals(r.Title, Title) &&
|
||||||
|
string.Equals(r.SubTitle, SubTitle) &&
|
||||||
|
r.Score == Score;
|
||||||
|
return equality;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -57,7 +60,9 @@ namespace Wox.Plugin
|
|||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
var hashcode = (Title?.GetHashCode() ?? 0) ^ (SubTitle?.GetHashCode() ?? 0);
|
var hashcode = (Title?.GetHashCode() ?? 0) ^
|
||||||
|
(SubTitle?.GetHashCode() ?? 0) ^
|
||||||
|
(Score.GetHashCode());
|
||||||
return hashcode;
|
return hashcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user