|
1 | 1 | @page "/tutorials/template5" |
2 | 2 | @layout TutorialsLayout |
| 3 | +@inherits WebSiteModuleComponentBase |
| 4 | +@attribute [JSModuleAutoLoader("Samples/Tutorials/LoginAndRegister/Template5.razor.js", AutoInvokeDispose = false)] |
3 | 5 |
|
4 | 6 | <HeadContent> |
5 | 7 | <style> |
|
21 | 23 |
|
22 | 24 | <div class="background-image"> |
23 | 25 | <div class="login-container"> |
24 | | - <div class="login-box animate-fade-in"> |
25 | | - <div class="header-row"> |
| 26 | + <div class="login-box animate-fade-in" id="@Id"> |
| 27 | + <div class="login-header"> |
26 | 28 | @if (!isAuth) |
27 | 29 | { |
28 | 30 | if (isEmailEntered) |
|
45 | 47 | </div> |
46 | 48 | } |
47 | 49 | </div> |
48 | | - @if (!isEmailEntered) |
49 | | - { |
50 | | - <h3>登录</h3> |
51 | | - <p class="subtitle">使用你的 BootstrapBlazor 帐户。</p> |
52 | | - <ValidateForm Model="_loginModel" OnValidSubmit="OnEmailSubmit"> |
53 | | - <BootstrapInput type="email" class="input" SkipValidate="true" IsAutoFocus="true" |
54 | | - placeholder="电子邮件或电话号码" @bind-Value="@_loginModel.Email"></BootstrapInput> |
55 | | - <div class="error" hidden="@(!showEmailError)">请输入有效的电子邮件地址或电话号码</div> |
56 | | - <Button class="button" Color="Color.Primary" ButtonType="ButtonType.Submit" Text="下一步"></Button> |
57 | | - </ValidateForm> |
58 | | - <div class="links"> |
59 | | - <a href="#" @onclick:preventDefault>忘记用户名?</a> |
60 | | - </div> |
61 | | - <div class="small"> |
62 | | - 不熟悉 BootstrapBlazor?<a href="/">去看文档</a> |
63 | | - </div> |
64 | | - } |
65 | | - else if (!isAuth) |
66 | | - { |
67 | | - <h3>输入你的密码</h3> |
68 | | - <p class="email-display">@_loginModel.Email</p> |
69 | | - <ValidateForm Model="_loginModel" OnValidSubmit="OnPasswordSubmit"> |
70 | | - <BootstrapInput type="password" class="input" SkipValidate="true" IsAutoFocus="true" |
71 | | - placeholder="密码" @bind-Value="@_loginModel.Password"></BootstrapInput> |
72 | | - <div class="links"> |
73 | | - <a href="#" @onclick:preventDefault>忘记了密码?</a> |
74 | | - </div> |
75 | | - <Button class="button" Color="Color.Primary" ButtonType="ButtonType.Submit" Text="下一步"></Button> |
76 | | - </ValidateForm> |
77 | | - <div class="links"> |
78 | | - <a href="#" @onclick:preventDefault>其他登录方法</a> |
79 | | - </div> |
80 | | - } |
81 | | - else |
| 50 | + @if (isAuth) |
82 | 51 | { |
83 | 52 | <div class="email-display2"><span>@_loginModel.Email</span></div> |
84 | 53 | <h5 class="text-center mt-3 mb-0">欢迎,您已成功登录</h5> |
85 | 54 | <div class="login-video-wrap"> |
86 | | - <video class="login-video" autoplay="autoplay" playsinline="playsinline" disablepictureinpicture=""> |
| 55 | + <video class="login-video" autoplay playsinline disablepictureinpicture> |
87 | 56 | <source src="samples/login5/loading1.mp4" type="video/mp4; codecs=av01.0.05M.08"> |
88 | 57 | <source src="samples/login5/loading.mov" type="video/quicktime; codecs=hvc1.1.6.H120.b0"> |
89 | 58 | <source src="samples/login5/loading.webm" type="video/webm; codecs=vp9"> |
|
92 | 61 | </video> |
93 | 62 | </div> |
94 | 63 | <p class="text-center text-muted" style="font-size: 0.75rem;">此登录高仿微软登录 UI</p> |
95 | | - <Button class="button" Color="Color.Primary">进入</Button> |
| 64 | + <Button class="button" Color="Color.Primary" OnClick="OnReset">进入</Button> |
| 65 | + } |
| 66 | + else |
| 67 | + { |
| 68 | + <div class="login-body"> |
| 69 | + <div class="login-item login-item-email show"> |
| 70 | + <h3>登录</h3> |
| 71 | + <p class="subtitle">使用你的 BootstrapBlazor 帐户。</p> |
| 72 | + <ValidateForm Model="_loginModel" OnValidSubmit="OnEmailSubmit"> |
| 73 | + <BootstrapInput type="email" class="input" SkipValidate="true" IsAutoFocus="true" |
| 74 | + placeholder="电子邮件或电话号码" @bind-Value="@_loginModel.Email"></BootstrapInput> |
| 75 | + <div class="error" hidden="@(!showEmailError)">请输入有效的电子邮件地址或电话号码</div> |
| 76 | + <Button class="button" Color="Color.Primary" ButtonType="ButtonType.Submit" Text="下一步"></Button> |
| 77 | + </ValidateForm> |
| 78 | + <div class="links"> |
| 79 | + <a href="#" @onclick:preventDefault>忘记用户名?</a> |
| 80 | + </div> |
| 81 | + <div class="small"> |
| 82 | + 不熟悉 BootstrapBlazor?<a href="/">去看文档</a> |
| 83 | + </div> |
| 84 | + </div> |
| 85 | + |
| 86 | + <div class="login-item login-item-password"> |
| 87 | + <h3>输入你的密码</h3> |
| 88 | + <p class="email-display">@_loginModel.Email</p> |
| 89 | + <ValidateForm Model="_loginModel" OnValidSubmit="OnPasswordSubmit"> |
| 90 | + <BootstrapInput type="password" class="input" SkipValidate="true" IsAutoFocus="true" |
| 91 | + placeholder="密码" @bind-Value="@_loginModel.Password"></BootstrapInput> |
| 92 | + <div class="links"> |
| 93 | + <a href="#" @onclick:preventDefault>忘记了密码?</a> |
| 94 | + </div> |
| 95 | + <Button class="button" Color="Color.Primary" ButtonType="ButtonType.Submit" Text="登录"></Button> |
| 96 | + </ValidateForm> |
| 97 | + <div class="links"> |
| 98 | + <a href="#" @onclick:preventDefault>其他登录方法</a> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + </div> |
96 | 102 | } |
97 | 103 | </div> |
98 | 104 | </div> |
99 | 105 | </div> |
100 | | - |
101 | | -@code { |
102 | | - private bool isEmailEntered = false; |
103 | | - private bool isAuth = false; |
104 | | - private bool showEmailError = false; |
105 | | - private LoginModel _loginModel = new LoginModel() |
106 | | - { |
107 | | - |
108 | | - Password = "123456" |
109 | | - }; |
110 | | - |
111 | | - private Task OnEmailSubmit(EditContext context) |
112 | | - { |
113 | | - if (string.IsNullOrWhiteSpace(_loginModel.Email)) |
114 | | - { |
115 | | - showEmailError = true; |
116 | | - } |
117 | | - else |
118 | | - { |
119 | | - showEmailError = false; |
120 | | - isEmailEntered = true; |
121 | | - } |
122 | | - StateHasChanged(); |
123 | | - return Task.CompletedTask; |
124 | | - } |
125 | | - |
126 | | - private Task OnPasswordSubmit(EditContext context) |
127 | | - { |
128 | | - // 数据库检查密码逻辑可以在这里实现 |
129 | | - // 演示代码一律通过 |
130 | | - isAuth = true; |
131 | | - StateHasChanged(); |
132 | | - return Task.CompletedTask; |
133 | | - } |
134 | | - |
135 | | - private void GoBack() |
136 | | - { |
137 | | - isEmailEntered = false; |
138 | | - } |
139 | | - |
140 | | - class LoginModel |
141 | | - { |
142 | | - public string? Email { get; set; } |
143 | | - |
144 | | - public string? Password { get; set; } |
145 | | - } |
146 | | -} |
0 commit comments