Skip to content

Commit

Permalink
使用新的密码框组件
Browse files Browse the repository at this point in the history
  • Loading branch information
JiuLing-zhang committed Dec 28, 2024
1 parent 596c8eb commit a6c27db
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 41 deletions.
27 changes: 15 additions & 12 deletions src/ComputerLock/Components/ResetPassword.razor
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<MudDialog>
<DialogContent>
<MudTextField @bind-Value="_currentPassword"
Label="@(Lang["CurrentPassword"])"
InputType="InputType.Password"
Variant="Variant.Text" />
<MudPaper Width="350px" Elevation="0">
<MudPasswordField @bind-Value="@_currentPassword"
Variant="Variant.Text"
Label="@(Lang["CurrentPassword"])"
IconSize="Size.Small" />

<MudTextField @bind-Value="_newPassword"
Label="@(Lang["NewPassword"])"
InputType="InputType.Password"
Variant="Variant.Text" />
<MudPasswordField @bind-Value="@_newPassword"
Class="my-2"
Variant="Variant.Text"
Label="@(Lang["NewPassword"])"
IconSize="Size.Small" />

<MudTextField @bind-Value="_confirmPassword"
Label="@(Lang["ConfirmPassword"])"
InputType="InputType.Password"
Variant="Variant.Text" />
<MudPasswordField @bind-Value="@_confirmPassword"
Variant="Variant.Text"
Label="@(Lang["ConfirmPassword"])"
IconSize="Size.Small" />
</MudPaper>
</DialogContent>
<DialogActions>
<MudButton Color="Color.Primary"
Expand Down
14 changes: 5 additions & 9 deletions src/ComputerLock/Components/SetPassword.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<MudTextField @bind-Value="_password"
Class="mt-6"
Label="@(Lang["SetPasswordInput"])"
Variant="Variant.Text"
InputType="@_passwordInputType"
Adornment="Adornment.End"
AdornmentIcon="@_passwordInputIcon"
IconSize="Size.Small"
OnAdornmentClick="ShowPassword" />
<MudPasswordField @bind-Value="@_password"
Class="mt-6"
Variant="Variant.Text"
Label="@(Lang["SetPasswordInput"])"
IconSize="Size.Small" />

<MudButton Class="mt-4"
FullWidth="true"
Expand Down
20 changes: 0 additions & 20 deletions src/ComputerLock/Components/SetPassword.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ public partial class SetPassword
[Inject]
private ISnackbar Snackbar { get; set; } = default!;


private bool _isShow;
private string _password = "";
private InputType _passwordInputType = InputType.Password;
private string _passwordInputIcon = Icons.Material.Filled.VisibilityOff;

[Parameter]
public EventCallback<string> PasswordSetFinished { get; set; }
Expand All @@ -21,22 +17,6 @@ protected override async Task OnInitializedAsync()
await base.OnInitializedAsync();
}

private void ShowPassword()
{
if (_isShow)
{
_isShow = false;
_passwordInputIcon = Icons.Material.Filled.VisibilityOff;
_passwordInputType = InputType.Password;
}
else
{
_isShow = true;
_passwordInputIcon = Icons.Material.Filled.Visibility;
_passwordInputType = InputType.Text;
}
}

private async Task SavePasswordAsync()
{
if (_password.IsEmpty())
Expand Down

0 comments on commit a6c27db

Please sign in to comment.