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>
|
/// <summary>
|
||||||
/// 从备份文件恢复使用统计数据
|
/// 从备份文件恢复使用统计数据
|
||||||
|
|||||||
@@ -53,29 +53,25 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
var lastCheckTime = DeviceIdentifier.GetLastUpdateCheck();
|
||||||
if (File.Exists(lastCheckTimePath))
|
if (lastCheckTime != DateTime.MinValue)
|
||||||
{
|
{
|
||||||
var timeStr = File.ReadAllText(lastCheckTimePath);
|
var now = DateTime.Now;
|
||||||
if (DateTime.TryParse(timeStr, out var lastCheckTime))
|
var timeDiff = now - lastCheckTime;
|
||||||
|
|
||||||
|
if (timeDiff.TotalDays < 1 && lastCheckTime.Date == now.Date)
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
LastCheckTimeText.Text = $"上次检查时间: 今天, {lastCheckTime:HH:mm}";
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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 = "上次检查时间: 从未";
|
LastCheckTimeText.Text = "上次检查时间: 从未";
|
||||||
}
|
}
|
||||||
@@ -89,8 +85,7 @@ namespace Ink_Canvas.Windows.SettingsViews
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var lastCheckTimePath = Path.Combine(App.RootPath, "last_update_check.dat");
|
DeviceIdentifier.RecordUpdateCheck();
|
||||||
File.WriteAllText(lastCheckTimePath, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
||||||
LoadLastCheckTime();
|
LoadLastCheckTime();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in New Issue
Block a user