Skip to content

Commit

Permalink
v0.9.6.1 Release!
Browse files Browse the repository at this point in the history
1.支持词云蒙版,现在可以自定义词云形状啦!
2.导出附件按用户id归集。
3.修复图片不存在导致导出线程退出的问题
  • Loading branch information
SuxueCode committed Dec 18, 2023
1 parent 6234ad3 commit 49c39b1
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Helpers/DecryptionHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public static byte[] DecryptDB(byte[] db_file_bytes, byte[] password_bytes)
var page_bytes = BitConverter.GetBytes(page_no + 1);
page_bytes.CopyTo(going_to_hashed, DEFAULT_PAGESIZE - reserved - offset + IV_SIZE);
//计算分页的Hash
var hash_mac_compute = hmac_sha1.ComputeHash(going_to_hashed, 0, going_to_hashed.Count());
var hash_mac_compute = hmac_sha1.ComputeHash(going_to_hashed, 0, going_to_hashed.Length);
//取出分页中存储的Hash
var hash_mac_cached = db_file_bytes.Skip((page_no * DEFAULT_PAGESIZE) + DEFAULT_PAGESIZE - reserved + IV_SIZE).Take(hash_mac_compute.Length).ToArray();
//对比两个Hash
Expand Down Expand Up @@ -229,7 +229,7 @@ private static string BytesToHex(byte[] bytes)
return BitConverter.ToString(bytes, 0).Replace("-", string.Empty).ToLower().ToUpper();
}

private static List<byte[]> ImgHeader = new List<byte[]>()
private readonly static List<byte[]> ImgHeader = new List<byte[]>()
{
new byte[] { 0xFF, 0xD8 },//JPG
new byte[] { 0x89, 0x50 },//PNG
Expand Down
20 changes: 14 additions & 6 deletions Pages/Workspace.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,13 @@ private void Export_Click(object sender, RoutedEventArgs e)
{
if(UserReader != null && ViewModel.WXContact != null)
{
System.Drawing.Image? mask = null;
if (File.Exists("mask.png"))
mask = System.Drawing.Image.FromFile("mask.png");

WordCloudSettingViewModel setting = new WordCloudSettingViewModel() {
ImgWidth = "1000",
ImgHeight = "1000",
ImgWidth = mask == null ? "1000": mask.Width.ToString(),
ImgHeight = mask == null ? "1000" : mask.Height.ToString(),
EnableRemoveOneKey = true,
};
Dispatcher.Invoke(() => {
Expand Down Expand Up @@ -190,15 +194,19 @@ private void Export_Click(object sender, RoutedEventArgs e)
ViewModel.ExportCount = "渲染词云结果";
string resultPath = "result.jpg";

var wordCloud = new WordCloud(int.Parse(setting.ImgWidth), int.Parse(setting.ImgHeight), allowVerical: true, fontname: setting.Font);
WordCloud wordCloud;
if(mask != null)
wordCloud = new WordCloud(int.Parse(setting.ImgWidth), int.Parse(setting.ImgHeight), mask: mask, allowVerical: true, fontname: setting.Font);
else
wordCloud = new WordCloud(int.Parse(setting.ImgWidth), int.Parse(setting.ImgHeight), allowVerical: true, fontname: setting.Font);

if(orderBy.Count() >= setting.MaxKeyCount)
if (orderBy.Count() >= setting.MaxKeyCount)
orderBy = orderBy.Take(setting.MaxKeyCount);
//var wordCloud = new WordCloud(1000, 1000,false, null,-1,1,null, false);

var result = wordCloud.Draw(orderBy.Select(it => it.Key).ToList(), orderBy.Select(it => it.Value).ToList());
result.Save(resultPath);
ViewModel.ExportCount = "完成";
MessageBox.Show("生成完毕", "提示");
MessageBox.Show("生成完毕,请查看软件根目录result.jpg", "提示");
}
return;
}
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
C# + .NET6.0 + WPF <br/>
- [x] ~~新版本UI界面开发~~
- [x] 完善各类消息支持(已经初步完成)
- [x] ~~词云~~
- [ ] 性能优化
- [ ] 词云
- [ ] 打包资源文件夹
- [ ] 手动模式(合适离线分析)
<br/>
Expand All @@ -53,6 +53,9 @@ A:<b>在手机端</b>使用迁移功能即可,路径:我->设置->聊天->
Q:怎么导出全部的记录<br/>
A:工作区->右键->管理,就见了。<br/>
<br/>
Q:解密工作区提示no such teble:MSG怎么办<br/>
A:基本上都是因为刚迁移完,缓存没写入到数据库导致的,建议迁移完重启一次微信后再创建工作区<br/>
<br/>

### 使用说明
**本说明为新版本说明,即将发版**<br/>
Expand Down
18 changes: 10 additions & 8 deletions WXUserReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void PreDownloadEmoji(string username = "")
}
else
{
string path = Path.Combine(UserBakConfig.UserWorkspacePath, "Emoji", md5 + ".gif");
string path = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Emoji", md5 + ".gif");
try
{
HttpResponseMessage res = httpClient.GetAsync(url).Result;
Expand Down Expand Up @@ -511,7 +511,7 @@ public List<WXMsg> GetTypeMsg(string type,string username)
if (UserBakConfig == null)
return null;

string? tmpPath = Path.Combine(UserBakConfig.UserWorkspacePath, "Temp");
string? tmpPath = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Temp");
if (!Directory.Exists(tmpPath))
Directory.CreateDirectory(tmpPath);

Expand Down Expand Up @@ -576,15 +576,15 @@ public List<WXMsg> GetTypeMsg(string type,string username)
// 获取到原路径后,开始进行解密转移,只有图片和语音需要解密,解密后是直接归档目录
if (type == WXMsgType.Image || type == WXMsgType.Audio)
{
path = DecryptAttachment(type, path);
path = DecryptAttachment(type, path, msg.StrTalker);
}
else if (type == WXMsgType.Video || type == WXMsgType.File)
{
string to_dir;
if (type == WXMsgType.Video)
to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "Video");
to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Video");
else
to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "File");
to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "File");
if (!Directory.Exists(to_dir))
Directory.CreateDirectory(to_dir);
FileInfo fileInfo = new FileInfo(path);
Expand Down Expand Up @@ -615,7 +615,7 @@ public List<WXMsg> GetTypeMsg(string type,string username)
return path;

}
public string? DecryptAttachment(WXMsgType type, string path)
public string? DecryptAttachment(WXMsgType type, string path,string username)
{
if (UserBakConfig == null)
return null;
Expand All @@ -624,19 +624,21 @@ public List<WXMsg> GetTypeMsg(string type,string username)
switch (type)
{
case WXMsgType.Image:
string img_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "Image");
string img_dir = Path.Combine(UserBakConfig.UserWorkspacePath, username, "Image");
if (!Directory.Exists(img_dir))
Directory.CreateDirectory(img_dir);
// 图片的路径是相对路径,需要加上资源目录
path = Path.Combine(UserBakConfig.UserResPath, path);
if (!File.Exists(path))
return null;
byte[] decFileByte = DecryptionHelper.DecImage(path);
if (decFileByte.Length < 2)
new Exception("解密失败,可能是未支持的格式");
string decFiletype = DecryptionHelper.CheckFileType(decFileByte);
file_path = DecryptionHelper.SaveDecImage(decFileByte, path, img_dir, decFiletype);
break;
case WXMsgType.Audio:
string audio_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "Audio");
string audio_dir = Path.Combine(UserBakConfig.UserWorkspacePath, username, "Audio");
if (!Directory.Exists(audio_dir))
Directory.CreateDirectory(audio_dir);
FileInfo fileInfo = new FileInfo(path);
Expand Down
9 changes: 6 additions & 3 deletions WechatBakTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.9.6.0</AssemblyVersion>
<FileVersion>0.9.6.0</FileVersion>
<Version>0.9.6.0</Version>
<AssemblyVersion>0.9.6.1</AssemblyVersion>
<FileVersion>0.9.6.1</FileVersion>
<Version>0.9.6.1</Version>
</PropertyGroup>

<ItemGroup>
Expand All @@ -29,6 +29,9 @@
<None Update="libssl-1_1.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="mask.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Resources\char_state_tab.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Binary file added mask.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 49c39b1

Please sign in to comment.