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

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,12 +40,15 @@ namespace SpineViewer.Utils
/// <summary> /// <summary>
/// 从文件反序列对象, 不会抛出异常 /// 从文件反序列对象, 不会抛出异常
/// </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 (!File.Exists(path))
{ {
_logger.Error("Json file {0} not found", path); if (!quietForNotExist)
MessagePopupService.Error($"Json file {path} not found"); {
_logger.Error("Json file {0} not found", path);
MessagePopupService.Error($"Json file {path} not found");
}
} }
else else
{ {

View File

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