UpdateUserInfo()添加异常捕获

croire 3 years ago
parent 59c75e3fdd
commit 73b2fa9739

@ -238,54 +238,62 @@ namespace DownKyi.ViewModels
return; return;
} }
await Task.Run(new Action(() => try
{ {
// 获取用户信息 await Task.Run(new Action(() =>
var userInfo = UserInfo.GetUserInfoForNavigation();
if (userInfo != null)
{ {
SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings // 获取用户信息
var userInfo = UserInfo.GetUserInfoForNavigation();
if (userInfo != null)
{ {
Mid = userInfo.Mid, SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
Name = userInfo.Name, {
IsLogin = userInfo.IsLogin, Mid = userInfo.Mid,
IsVip = userInfo.VipStatus == 1 Name = userInfo.Name,
}); IsLogin = userInfo.IsLogin,
} IsVip = userInfo.VipStatus == 1
else });
{ }
SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings else
{ {
Mid = -1, SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
Name = "", {
IsLogin = false, Mid = -1,
IsVip = false Name = "",
}); IsLogin = false,
} IsVip = false
});
PropertyChangeAsync(new Action(() => }
{
LoginPanelVisibility = Visibility.Visible;
if (userInfo != null) PropertyChangeAsync(new Action(() =>
{ {
if (userInfo.Face != null) LoginPanelVisibility = Visibility.Visible;
if (userInfo != null)
{ {
Header = new StorageHeader().GetHeaderThumbnail(userInfo.Mid, userInfo.Name, userInfo.Face, 36, 36); if (userInfo.Face != null)
{
Header = new StorageHeader().GetHeaderThumbnail(userInfo.Mid, userInfo.Name, userInfo.Face, 36, 36);
}
else
{
Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
}
UserName = userInfo.Name;
} }
else else
{ {
Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg")); Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
UserName = null;
} }
UserName = userInfo.Name; }));
}
else
{
Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
UserName = null;
}
})); }));
})); }
catch (Exception e)
{
Core.Utils.Debugging.Console.PrintLine("UpdateUserInfo()发生异常: {0}", e);
LogManager.Error(Tag, e);
}
} }
#endregion #endregion

Loading…
Cancel
Save