Skip to content

Commit

Permalink
feat: init data & reload data
Browse files Browse the repository at this point in the history
  • Loading branch information
Daydreamer-riri committed Mar 15, 2024
1 parent 211d247 commit 8a289d2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
18 changes: 18 additions & 0 deletions Community.PowerToys.Run.Plugin.WebSearchShortcut/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ public List<Result> Query(Query query)

var args = query.Search;

if (args.Trim() == "!reload")
{
return
[
new()
{
Title = "Reload data",
SubTitle = "Reloads the data from the file",
IcoPath = IconPath,
Action = _ =>
{
ReloadData();
return true;
},
},
];
}

if (string.IsNullOrEmpty(args))
{
return WebSearchShortcutStorage.GetRecords().Select(GetResultForGetRecord).ToList();
Expand Down
12 changes: 11 additions & 1 deletion Community.PowerToys.Run.Plugin.WebSearchShortcut/Storage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,17 @@ public void Load()

if (!File.Exists(path))
{
File.WriteAllText(path, "{}");
var initData = new Dictionary<string, Item>
{
{ "google", new Item { KeyWord = "google", Name = "Google", Url = "https://www.google.com/search?q={q}" } },
{ "bing", new Item { KeyWord = "bing", Name = "Bing", Url = "https://www.bing.com/search?q={q}" } },
{ "duckduckgo", new Item { KeyWord = "duckduckgo", Name = "DuckDuckGo", Url = "https://duckduckgo.com/?q={q}" } },
{ "youtube", new Item { KeyWord = "youtube", Name = "YouTube", Url = "https://www.youtube.com/results?search_query={q}" } },
{ "github", new Item { KeyWord = "github", Name = "GitHub", Url = "" } },
};

var json = JsonSerializer.Serialize(initData, _serializerOptions);
File.WriteAllText(path, json);
}

try
Expand Down
Binary file modified WebSearchShortcut-0.0.1-ARM64.zip
Binary file not shown.
Binary file modified WebSearchShortcut-0.0.1-x64.zip
Binary file not shown.

0 comments on commit 8a289d2

Please sign in to comment.