Skip to content

Commit

Permalink
Fix empty Synonym
Browse files Browse the repository at this point in the history
  • Loading branch information
Null committed Jan 27, 2018
1 parent 6d07276 commit 8b3ceec
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ private List<Result> DetailedQuery(Query query)
results.Add(MakeResultItem("Definition", word.definition.Replace("\n", "; "), "d"));
if (word.exchange != "")
results.Add(MakeResultItem("Exchanges", word.exchange, "e"));
results.Add(MakeResultItem("Synonym", String.Join("; ", synonyms.Query(word.word)), "s"));

var synonymsResult = String.Join("; ", synonyms.Query(word.word));
if (synonymsResult != "")
results.Add(MakeResultItem("Synonym", synonymsResult, "s"));
return results;
}

Expand Down
51 changes: 51 additions & 0 deletions src/Downloader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using SevenZip;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace Dictionary
{
class Downloader
{
const string URL = "https://coding.net/u/nullptr_t/p/ECDICT-sqlite/git/raw/master/ecdict.7z";
string rootPath;

public Downloader(string rootPath)
{
this.rootPath = rootPath;
}

public void Download()
{
if (!File.Exists(rootPath + "dicts\\dict.7z.tmp"))
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += WebClient_DownloadFileCompleted;
webClient.DownloadFileAsync(new Uri(URL), rootPath + "dicts\\dict.7z.tmp");
}
else
{
Decompress7Zip(rootPath + "dicts\\", "dict.7z.tmp");
File.Delete(rootPath + "dicts\\dict.7z.tmp");
}
}

private void WebClient_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
Decompress7Zip(rootPath + "dicts\\", "dict.7z.tmp");
File.Delete(rootPath + "dicts\\dict.7z.tmp");
}

private void Decompress7Zip(string path, string fileName)
{
SevenZipExtractor.SetLibraryPath("7zxa.dll");
new SevenZipExtractor(path + fileName).ExtractArchive(path);
MessageBox.Show("Download successfully", "Download successfully. Restart Wox to apply. 下载成功!请重启 Wox 来使用词典。");
}
}
}

0 comments on commit 8b3ceec

Please sign in to comment.