From cc8863085952433231b683be430180e2c18d5541 Mon Sep 17 00:00:00 2001
From: CJK_mkp <113243675+CJKmkp@users.noreply.github.com>
Date: Mon, 18 Aug 2025 17:54:41 +0800
Subject: [PATCH] =?UTF-8?q?fix:=E5=85=B3=E6=9C=BA=E6=97=B6=E4=B8=8D?=
=?UTF-8?q?=E4=BF=9D=E5=AD=98=E4=BD=BF=E7=94=A8=E6=95=B0=E6=8D=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Ink Canvas/Helpers/DeviceIdentifier.cs | 108 -------------------------
1 file changed, 108 deletions(-)
diff --git a/Ink Canvas/Helpers/DeviceIdentifier.cs b/Ink Canvas/Helpers/DeviceIdentifier.cs
index 274d46e7..0ee14e12 100644
--- a/Ink Canvas/Helpers/DeviceIdentifier.cs
+++ b/Ink Canvas/Helpers/DeviceIdentifier.cs
@@ -2782,113 +2782,5 @@ namespace Ink_Canvas.Helpers
}
}
}
-
- ///
- /// 加载现有使用统计数据(从主文件或备份)
- ///
- private static UsageStats LoadUsageStats()
- {
- // 尝试从主文件加载
- if (File.Exists(UsageStatsFilePath))
- {
- try
- {
- string json = File.ReadAllText(UsageStatsFilePath);
- return JsonConvert.DeserializeObject(json);
- }
- catch
- {
- // 主文件损坏,尝试从备份加载
- if (File.Exists(BackupUsageStatsPath))
- {
- try
- {
- string backupJson = File.ReadAllText(BackupUsageStatsPath);
- return JsonConvert.DeserializeObject(backupJson);
- }
- catch
- {
- // 可继续尝试其他备份路径
- return LoadFromOtherBackups();
- }
- }
- }
- }
- return null;
- }
-
- ///
- /// 从其他备份路径加载数据
- ///
- private static UsageStats LoadFromOtherBackups()
- {
- // 尝试二级备份
- if (File.Exists(SecondaryUsageBackupPath))
- {
- try
- {
- return JsonConvert.DeserializeObject(File.ReadAllText(SecondaryUsageBackupPath));
- }
- catch { }
- }
-
- // 尝试三级备份
- if (File.Exists(TertiaryUsageBackupPath))
- {
- try
- {
- return JsonConvert.DeserializeObject(File.ReadAllText(TertiaryUsageBackupPath));
- }
- catch { }
- }
-
- // 尝试四级备份
- if (File.Exists(QuaternaryUsageBackupPath))
- {
- try
- {
- return JsonConvert.DeserializeObject(File.ReadAllText(QuaternaryUsageBackupPath));
- }
- catch { }
- }
-
- return null;
- }
-
- ///
- /// 保存使用统计数据到所有备份位置
- ///
- private static void SaveUsageStatsToAllLocations(UsageStats stats)
- {
- string json = JsonConvert.SerializeObject(stats, Formatting.Indented);
-
- // 保存到主文件
- SaveToFile(UsageStatsFilePath, json);
- // 保存到多重备份路径
- SaveToFile(BackupUsageStatsPath, json);
- SaveToFile(SecondaryUsageBackupPath, json);
- SaveToFile(TertiaryUsageBackupPath, json);
- SaveToFile(QuaternaryUsageBackupPath, json);
- }
-
- ///
- /// 辅助方法:保存内容到文件(确保目录存在)
- ///
- private static void SaveToFile(string path, string content)
- {
- try
- {
- string dir = Path.GetDirectoryName(path);
- if (!Directory.Exists(dir))
- {
- Directory.CreateDirectory(dir);
- }
- File.WriteAllText(path, content);
- }
- catch (Exception ex)
- {
- LogHelper.WriteLogToFile($"保存文件 {path} 失败: {ex.Message}", LogHelper.LogType.Warning);
- }
- }
}
}