Jelajahi Sumber

v0.9.6.1 Release!
1.支持词云蒙版,现在可以自定义词云形状啦!
2.导出附件按用户id归集。
3.修复图片不存在导致导出线程退出的问题

Suxue 1 tahun lalu
induk
melakukan
49c39b13cf
6 mengubah file dengan 36 tambahan dan 20 penghapusan
  1. 2 2
      Helpers/DecryptionHelper.cs
  2. 14 6
      Pages/Workspace.xaml.cs
  3. 4 1
      README.md
  4. 10 8
      WXUserReader.cs
  5. 6 3
      WechatBakTool.csproj
  6. TEMPAT SAMPAH
      mask.png

+ 2 - 2
Helpers/DecryptionHelper.cs

@@ -178,7 +178,7 @@ namespace WechatBakTool.Helpers
                 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
@@ -229,7 +229,7 @@ namespace WechatBakTool.Helpers
             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

+ 14 - 6
Pages/Workspace.xaml.cs

@@ -147,9 +147,13 @@ namespace WechatBakTool.Pages
                 {
                     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(() => {
@@ -190,15 +194,19 @@ namespace WechatBakTool.Pages
                         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;
                 }

+ 4 - 1
README.md

@@ -40,8 +40,8 @@
 C# + .NET6.0 + WPF <br/>
 - [x] ~~新版本UI界面开发~~
 - [x] 完善各类消息支持(已经初步完成)
+- [x] ~~词云~~
 - [ ] 性能优化
-- [ ] 词云
 - [ ] 打包资源文件夹
 - [ ] 手动模式(合适离线分析)
 <br/>
@@ -53,6 +53,9 @@ A:<b>在手机端</b>使用迁移功能即可,路径:我->设置->聊天->
 Q:怎么导出全部的记录<br/>
 A:工作区->右键->管理,就见了。<br/>
 <br/>
+Q:解密工作区提示no such teble:MSG怎么办<br/>
+A:基本上都是因为刚迁移完,缓存没写入到数据库导致的,建议迁移完重启一次微信后再创建工作区<br/>
+<br/>
 
 ### 使用说明
 **本说明为新版本说明,即将发版**<br/>

+ 10 - 8
WXUserReader.cs

@@ -162,7 +162,7 @@ namespace WechatBakTool
                             }
                             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;
@@ -511,7 +511,7 @@ namespace WechatBakTool
             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);
 
@@ -576,15 +576,15 @@ namespace WechatBakTool
             // 获取到原路径后,开始进行解密转移,只有图片和语音需要解密,解密后是直接归档目录
             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);
@@ -615,7 +615,7 @@ namespace WechatBakTool
             return path;
 
         }
-        public string? DecryptAttachment(WXMsgType type, string path)
+        public string? DecryptAttachment(WXMsgType type, string path,string username)
         {
             if (UserBakConfig == null)
                 return null;
@@ -624,11 +624,13 @@ namespace WechatBakTool
             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("解密失败,可能是未支持的格式");
@@ -636,7 +638,7 @@ namespace WechatBakTool
                     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);

+ 6 - 3
WechatBakTool.csproj

@@ -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>
@@ -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>

TEMPAT SAMPAH
mask.png