mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Web search suggestion is loaded async
1. suggestion is async 2. if ping time of domain less than 300ms, then suggestion is still sync 3. #578 #539
This commit is contained in:
@@ -2,20 +2,31 @@
|
||||
|
||||
namespace Wox.Plugin.WebSearch.SuggestionSources
|
||||
{
|
||||
public interface ISuggestionSource
|
||||
{
|
||||
List<string> GetSuggestions(string query);
|
||||
}
|
||||
|
||||
public abstract class AbstractSuggestionSource : ISuggestionSource
|
||||
public abstract class SuggestionSource
|
||||
{
|
||||
public virtual string Domain { get; set; }
|
||||
public IHttpProxy Proxy { get; set; }
|
||||
|
||||
public AbstractSuggestionSource(IHttpProxy httpProxy)
|
||||
public SuggestionSource(IHttpProxy httpProxy)
|
||||
{
|
||||
Proxy = httpProxy;
|
||||
}
|
||||
|
||||
public abstract List<string> GetSuggestions(string query);
|
||||
|
||||
public static SuggestionSource GetSuggestionSource(string name, PluginInitContext context)
|
||||
{
|
||||
switch (name.ToLower())
|
||||
{
|
||||
case "google":
|
||||
return new Google(context.Proxy);
|
||||
|
||||
case "baidu":
|
||||
return new Baidu(context.Proxy);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user