修复首选项文件不存在时的提示信息
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user