mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-11 12:14:53 +08:00
fix regressive issues
This commit is contained in:
parent
02e22e5781
commit
998eecb94d
@ -10,16 +10,20 @@ using Wox.Plugin.WebSearch.SuggestionSources;
|
||||
|
||||
namespace Wox.Plugin.WebSearch
|
||||
{
|
||||
public class WebQueryPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery
|
||||
public class WebSearchPlugin : IPlugin, ISettingProvider, IPluginI18n, IInstantQuery, IExclusiveQuery
|
||||
{
|
||||
private PluginInitContext context;
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
List<Result> results = new List<Result>();
|
||||
if (!query.Search.Contains(' '))
|
||||
{
|
||||
return results;
|
||||
}
|
||||
|
||||
WebSearch webSearch =
|
||||
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && !string.IsNullOrEmpty(query.SecondSearch) && o.Enabled);
|
||||
WebSearchStorage.Instance.WebSearches.FirstOrDefault(o => o.ActionWord == query.FirstSearch.Trim() && o.Enabled);
|
||||
|
||||
if (webSearch != null)
|
||||
{
|
||||
|
@ -67,6 +67,9 @@
|
||||
<Compile Include="WebSearchStorage.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Images\websearch\pictures.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="Languages\en.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
@ -131,7 +131,7 @@ namespace Wox.Core.Plugin
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if a query contains action keyword
|
||||
/// Check if a query contains valid action keyword
|
||||
/// </summary>
|
||||
/// <param name="query"></param>
|
||||
/// <returns></returns>
|
||||
@ -144,7 +144,19 @@ namespace Wox.Core.Plugin
|
||||
var actionKeyword = strings[0].Trim();
|
||||
if (string.IsNullOrEmpty(actionKeyword)) return false;
|
||||
|
||||
return plugins.Any(o => o.Metadata.ActionKeyword == actionKeyword);
|
||||
PluginPair pair = plugins.FirstOrDefault(o => o.Metadata.ActionKeyword == actionKeyword);
|
||||
if (pair != null)
|
||||
{
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.CustomizedPluginConfigs.FirstOrDefault(o => o.ID == pair.Metadata.ID);
|
||||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool IsGenericPlugin(PluginMetadata metadata)
|
||||
@ -292,15 +304,17 @@ namespace Wox.Core.Plugin
|
||||
|
||||
internal static PluginPair GetActionKeywordPlugin(Query query)
|
||||
{
|
||||
PluginPair exclusivePluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword());
|
||||
if (exclusivePluginPair != null)
|
||||
PluginPair actionKeywordPluginPair = AllPlugins.FirstOrDefault(o => o.Metadata.ActionKeyword == query.GetActionKeyword());
|
||||
if (actionKeywordPluginPair != null)
|
||||
{
|
||||
var customizedPluginConfig = UserSettingStorage.Instance.
|
||||
CustomizedPluginConfigs.FirstOrDefault(o => o.ID == exclusivePluginPair.Metadata.ID);
|
||||
if (customizedPluginConfig != null && !customizedPluginConfig.Disabled)
|
||||
CustomizedPluginConfigs.FirstOrDefault(o => o.ID == actionKeywordPluginPair.Metadata.ID);
|
||||
if (customizedPluginConfig != null && customizedPluginConfig.Disabled)
|
||||
{
|
||||
return exclusivePluginPair;
|
||||
return null;
|
||||
}
|
||||
|
||||
return actionKeywordPluginPair;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -13,8 +13,8 @@ namespace Wox.Plugin
|
||||
|
||||
/// <summary>
|
||||
/// Search part of a query.
|
||||
/// This will not include action keyword if regular plugin gets it, and if a system plugin gets it, it should be same as RawQuery.
|
||||
/// Since we allow user to switch a regular plugin to system plugin, so this property will always give you the "real" query part of
|
||||
/// This will not include action keyword if exclusive plugin gets it, otherwise it should be same as RawQuery.
|
||||
/// Since we allow user to switch a exclusive plugin to generic plugin, so this property will always give you the "real" query part of
|
||||
/// the query
|
||||
/// </summary>
|
||||
public string Search { get; internal set; }
|
||||
|
@ -31,6 +31,7 @@ namespace Wox.Test
|
||||
|
||||
Assert.IsFalse(urlPlugin.IsURL("wwww"));
|
||||
Assert.IsFalse(urlPlugin.IsURL("wwww.c"));
|
||||
Assert.IsFalse(urlPlugin.IsURL("wwww.c"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user