Skip to content

Commit

Permalink
当自动登录失败时弹出警告 (#853)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Oct 23, 2024
1 parent 38a38df commit e2d010f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2750,4 +2750,13 @@
<data name="ShowSearchRecommendDescription" xml:space="preserve">
<value>在顶部搜索框聚焦时提供搜索建议</value>
</data>
<data name="LoginExpiredDescription" xml:space="preserve">
<value>尝试获取用户信息失败,这可能是网络原因,也有可能是你近期修改了密码,请重新登录或退出后重启应用</value>
</data>
<data name="LoginExpiredTitle" xml:space="preserve">
<value>登录失败</value>
</data>
<data name="ReSignIn" xml:space="preserve">
<value>重新登录</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ private async Task InitializeAsync()
catch (Exception ex)
{
_logger.LogCritical(ex, "无法获取登录用户的资料");

// 用户可能更改了密码,提醒用户是否需要重新登录.
var dialog = new ContentDialog()
{
Title = ResourceToolkit.GetLocalizedString(Models.Constants.StringNames.LoginExpiredTitle),
Content = ResourceToolkit.GetLocalizedString(Models.Constants.StringNames.LoginExpiredDescription),
PrimaryButtonText = ResourceToolkit.GetLocalizedString(Models.Constants.StringNames.ReSignIn),
CloseButtonText = ResourceToolkit.GetLocalizedString(Models.Constants.StringNames.Exit),
DefaultButton = ContentDialogButton.Primary,
XamlRoot = this.Get<AppViewModel>().ActivatedWindow.Content.XamlRoot,
};

var result = await dialog.ShowAsync();
if (result == ContentDialogResult.Primary)
{
await SignOutAsync();
}
else
{
App.Current.Exit();
}
}

IsInitializing = false;
Expand Down

0 comments on commit e2d010f

Please sign in to comment.