1+ @page
2+ @using Microsoft .AspNetCore .Mvc .Localization
3+ @using Volo .Abp .AspNetCore .Mvc .UI .Layout
4+ @using Volo .Abp .AspNetCore .Mvc .UI .Theming ;
5+ @using Volo .Abp .OpenIddict .Localization
6+ @using LINGYUN .Abp .Account .Web .OpenIddict .Pages .Account
7+ @inject IThemeManager ThemeManager
8+ @inject IPageLayout PageLayout
9+ @inject IHtmlLocalizer <AbpOpenIddictResource > L
10+ @model SelectAccountModel
11+
12+ @{
13+ Layout = ThemeManager .CurrentTheme .GetAccountLayout ();
14+ PageLayout .Content .Title = L [" SelectAccount" ].Value ;
15+ }
16+
17+ @section styles
18+ {
19+ <abp-style-bundle name =" @typeof(SelectAccountModel).FullName" />
20+ }
21+
22+ @section scripts
23+ {
24+ <abp-script-bundle name =" @typeof(SelectAccountModel).FullName" />
25+ }
26+
27+ <abp-card >
28+ <abp-card-body >
29+ @if (Model .AvailableAccounts .Any ())
30+ {
31+ <form method =" post" id =" selectAccountForm" >
32+ @Html.AntiForgeryToken()
33+
34+ <input type =" hidden" asp-for =" Input.ClientId" value =" @Model.ClientName" />
35+ <input type =" hidden" asp-for =" Input.RedirectUri" value =" @Model.RedirectUri" />
36+ <input type =" hidden" asp-for =" Input.RememberSelection" value =" true" />
37+ <input type =" hidden" asp-for =" Input.RememberMe" value =" true" />
38+
39+ <div class =" alert alert-info d-flex align-items-center mb-4" >
40+ <i class =" fas fa-user-check me-2" ></i >
41+ <span >@string.Format(@L ["SignedInAs "].Value , @Model.UserName) </span >
42+ </div >
43+
44+ <div class =" list-group list-group-flush rounded-3" >
45+ @for ( int i = 0 ; i < Model .AvailableAccounts .Count ; i ++ )
46+ {
47+ var account = Model .AvailableAccounts [i ];
48+ var accountId = $" {account .UserId }@{account .TenantId }" ;
49+ var accountName = $" {account .UserName }" ;
50+ if (! string .IsNullOrWhiteSpace (account .TenantName ))
51+ {
52+ accountName += " /" + account .TenantName ;
53+ }
54+ // TODO: Date format
55+ var lastLoginTime = account .LastLoginTime .HasValue ? account .LastLoginTime .Value .ToString (" yyyy-MM:dd HH:mm:ss" ) : " " ;
56+ var isCurrent = account .IsCurrentAccount ;
57+ // TODO: 实现用户头像
58+ var avatar = ! string .IsNullOrWhiteSpace (account .UserName ) ? account .UserName [0 ].ToString ().ToUpper () : " U" ;
59+
60+ <label class =" list-group-item list-group-item-action border-0 cursor-pointer @(isCurrent ? " active " : " " ) account-item"
61+ for =" account-@i" >
62+ <div class =" d-flex align-items-center" >
63+ <!-- 头像 -->
64+ <div class =" rounded-circle bg-primary text-white d-flex align-items-center justify-content-center me-3"
65+ style =" width : 40px ; height : 40px ; font-size : 16px ; font-weight : 500 ;" >
66+ @avatar
67+ </div >
68+
69+ <!-- 账户信息 -->
70+ <div class =" flex-grow-1 me-3" >
71+ <div class =" d-flex align-items-center" >
72+ <span class =" fw-semibold" >@accountName </span >
73+ @if (isCurrent )
74+ {
75+ <span class =" badge bg-success ms-2" >@L ["CurrentAccount "].Value </span >
76+ }
77+ </div >
78+ <div class =" text-muted small" >
79+ @account.Email
80+ </div >
81+ @if (! string .IsNullOrWhiteSpace (lastLoginTime ))
82+ {
83+ <div class =" text-muted small" >
84+ @L ["LastLoginTime "]: @lastLoginTime
85+ </div >
86+ }
87+ </div >
88+
89+ <!-- 选择账户 -->
90+ <input type =" radio"
91+ asp-for =" Input.SelectedAccountId"
92+ value =" @accountId"
93+ id =" account-@i"
94+ class =" form-check-input"
95+ style =" width : 1.2em ; height : 1.2em ;"
96+ checked =" @isCurrent" />
97+ </div >
98+ </label >
99+ }
100+ </div >
101+
102+ <!-- 操作按钮 -->
103+ <div class =" d-grid gap-2 mt-2" >
104+ <button type =" submit" class =" btn btn-primary" id =" continueButton" >
105+ @L ["Continue "].Value
106+ <i class =" fas fa-arrow-right" ></i >
107+ </button >
108+ </div >
109+ </form >
110+ }
111+ else
112+ {
113+ <div class =" alert alert-warning mb-4" >
114+ <i class =" fas fa-info-circle me-2" ></i >
115+ @L ["NoAccountsAvailable "].Value
116+ </div >
117+ }
118+
119+ <!-- 其他选项 -->
120+ <div class =" d-grid gap-2 mt-2" >
121+ <a href =" @Url.Page(" /Account /Login " , new { ReturnUrl = Model.RedirectUri, prompt = " login " })"
122+ class =" btn btn-outline-primary" >
123+ <i class =" fas fa-exchange-alt me-2" ></i >
124+ @L ["SwitchToAnotherAccount"].Value
125+ </a >
126+ <a href =" @Url.Page(" /Account /Register " , new { ReturnUrl = Model.RedirectUri })"
127+ class =" btn btn-outline-primary" >
128+ <i class =" fas fa-user-plus me-2" ></i >
129+ @L ["CreateNewAccount"].Value
130+ </a >
131+ </div >
132+ </abp-card-body >
133+ </abp-card >
0 commit comments