improve:信息保存
This commit is contained in:
@@ -960,6 +960,23 @@ namespace Ink_Canvas.Helpers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取上次更新检查时间
|
||||
/// </summary>
|
||||
public static DateTime GetLastUpdateCheck()
|
||||
{
|
||||
try
|
||||
{
|
||||
var stats = LoadUsageStats();
|
||||
return stats.LastUpdateCheck;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"DeviceIdentifier | 获取上次更新检查时间失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
return DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 从备份文件恢复使用统计数据
|
||||
|
||||
@@ -53,29 +53,25 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
try
|
||||
{
|
||||
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
||||
if (File.Exists(lastCheckTimePath))
|
||||
var lastCheckTime = DeviceIdentifier.GetLastUpdateCheck();
|
||||
if (lastCheckTime != DateTime.MinValue)
|
||||
{
|
||||
var timeStr = File.ReadAllText(lastCheckTimePath);
|
||||
if (DateTime.TryParse(timeStr, out var lastCheckTime))
|
||||
var now = DateTime.Now;
|
||||
var timeDiff = now - lastCheckTime;
|
||||
|
||||
if (timeDiff.TotalDays < 1 && lastCheckTime.Date == now.Date)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var timeDiff = now - lastCheckTime;
|
||||
|
||||
if (timeDiff.TotalDays < 1 && lastCheckTime.Date == now.Date)
|
||||
{
|
||||
LastCheckTimeText.Text = $"上次检查时间: 今天, {lastCheckTime:HH:mm}";
|
||||
}
|
||||
else if (timeDiff.TotalDays < 2 && lastCheckTime.Date == now.Date.AddDays(-1))
|
||||
{
|
||||
LastCheckTimeText.Text = $"上次检查时间: 昨天, {lastCheckTime:HH:mm}";
|
||||
}
|
||||
else
|
||||
{
|
||||
LastCheckTimeText.Text = $"上次检查时间: {lastCheckTime:yyyy-MM-dd HH:mm}";
|
||||
}
|
||||
return;
|
||||
LastCheckTimeText.Text = $"上次检查时间: 今天, {lastCheckTime:HH:mm}";
|
||||
}
|
||||
else if (timeDiff.TotalDays < 2 && lastCheckTime.Date == now.Date.AddDays(-1))
|
||||
{
|
||||
LastCheckTimeText.Text = $"上次检查时间: 昨天, {lastCheckTime:HH:mm}";
|
||||
}
|
||||
else
|
||||
{
|
||||
LastCheckTimeText.Text = $"上次检查时间: {lastCheckTime:yyyy-MM-dd HH:mm}";
|
||||
}
|
||||
return;
|
||||
}
|
||||
LastCheckTimeText.Text = "上次检查时间: 从未";
|
||||
}
|
||||
@@ -89,8 +85,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
||||
{
|
||||
try
|
||||
{
|
||||
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
||||
File.WriteAllText(lastCheckTimePath, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
DeviceIdentifier.RecordUpdateCheck();
|
||||
LoadLastCheckTime();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user