修复首选项文件不存在时的提示信息

This commit is contained in:
ww-rm
2025-06-19 22:54:12 +08:00
parent 7b58eeafe3
commit 7d1a1f1aeb
2 changed files with 7 additions and 4 deletions

View File

@@ -40,13 +40,16 @@ namespace SpineViewer.Utils
/// <summary>
/// 从文件反序列对象, 不会抛出异常
/// </summary>
public static bool Deserialize<T>(string path, out T obj)
public static bool Deserialize<T>(string path, out T obj, bool quietForNotExist = false)
{
if (!File.Exists(path))
{
if (!quietForNotExist)
{
_logger.Error("Json file {0} not found", path);
MessagePopupService.Error($"Json file {path} not found");
}
}
else
{
try

View File

@@ -63,7 +63,7 @@ namespace SpineViewer.ViewModels.MainWindow
/// </summary>
public void LoadPreference()
{
if (JsonHelper.Deserialize<PreferenceModel>(PreferenceFilePath, out var obj))
if (JsonHelper.Deserialize<PreferenceModel>(PreferenceFilePath, out var obj, true))
Preference = obj;
}