Skip to content

Commit 32da1ab

Browse files
committed
修改密码解锁可能失效的问题
1 parent bf813c2 commit 32da1ab

File tree

8 files changed

+68
-39
lines changed

8 files changed

+68
-39
lines changed

src/ComputerLock/Components/Settings/UnlockSettings.razor

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,18 @@
6363
Dense="true"
6464
Class="no-left-padding max-width-fix"
6565
Disabled="@(!isPasswordSelected)" />
66-
<MudCollapse Expanded="@(!AppSettings.EnablePasswordBox)">
67-
<MudText Typo="Typo.caption" Class="input-tip ml-7">
66+
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="input-tip ml-7" Style="opacity: 1">
67+
@if (AppSettings.EnablePasswordBox)
68+
{
69+
@(Lang["DisablePasswordBoxTips"])
70+
}
71+
else
72+
{
6873
@(Lang["EnablePasswordBoxTips"])
69-
</MudText>
70-
</MudCollapse>
74+
}
75+
</MudText>
76+
7177
<MudStack Class="ml-4 mt-4" Spacing="4">
72-
<MudCheckBox @bind-Value="@(AppSettings.IsHidePasswordWindow)"
73-
@bind-Value:after="SaveSettings"
74-
Disabled="@(!AppSettings.EnablePasswordBox || !isPasswordSelected)"
75-
Label="@(Lang["HidePasswordWindow"])"
76-
Color="Color.Primary"
77-
Class="no-left-padding max-width-fix"
78-
Dense="true" />
79-
<MudCheckBox @bind-Value="@(_keyboardDownChecked)"
80-
@bind-Value:after="KeyboardDownChecked"
81-
Disabled="@(!AppSettings.EnablePasswordBox || !isPasswordSelected)"
82-
Label="@(Lang["KeyboardDownActivePwd"])"
83-
Color="Color.Primary"
84-
Class="no-left-padding max-width-fix"
85-
Dense="true" />
86-
<MudCheckBox @bind-Value="@(_mouseDownChecked)"
87-
@bind-Value:after="MouseDownChecked"
88-
Disabled="@(!AppSettings.EnablePasswordBox || !isPasswordSelected)"
89-
Label="@(Lang["MouseDownActivePwd"])"
90-
Color="Color.Primary"
91-
Class="no-left-padding max-width-fix"
92-
Dense="true" />
9378
<div>
9479
<MudText Typo="Typo.subtitle2" Class="input-title">@(Lang["PwdLocation"])</MudText>
9580
<MudSelect T="ScreenLocationEnum"
@@ -109,6 +94,27 @@
10994
<MudSelectItem Value="@(ScreenLocationEnum.BottomRight)">@(Lang["BottomRight"])</MudSelectItem>
11095
</MudSelect>
11196
</div>
97+
<MudCheckBox @bind-Value="@(_keyboardDownChecked)"
98+
@bind-Value:after="KeyboardDownChecked"
99+
Disabled="@(!AppSettings.EnablePasswordBox || !isPasswordSelected)"
100+
Label="@(Lang["KeyboardDownActivePwd"])"
101+
Color="Color.Primary"
102+
Class="no-left-padding max-width-fix"
103+
Dense="true" />
104+
<MudCheckBox @bind-Value="@(_mouseDownChecked)"
105+
@bind-Value:after="MouseDownChecked"
106+
Disabled="@(!AppSettings.EnablePasswordBox || !isPasswordSelected)"
107+
Label="@(Lang["MouseDownActivePwd"])"
108+
Color="Color.Primary"
109+
Class="no-left-padding max-width-fix"
110+
Dense="true" />
111+
<MudCheckBox @bind-Value="@(AppSettings.IsHidePasswordWindow)"
112+
@bind-Value:after="SaveSettings"
113+
Disabled="@(!AppSettings.EnablePasswordBox || !isPasswordSelected)"
114+
Label="@(Lang["HidePasswordWindow"])"
115+
Color="Color.Primary"
116+
Class="no-left-padding max-width-fix"
117+
Dense="true" />
112118

113119
</MudStack>
114120
@if (!isPasswordSelected)

src/ComputerLock/Configuration/AppSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public void Initialize(HotkeyTools hotkeyTools)
124124
/// <summary>
125125
/// 启用密码框
126126
/// </summary>
127-
public bool EnablePasswordBox { get; set; } = false;
127+
public bool EnablePasswordBox { get; set; } = true;
128128

129129
/// <summary>
130130
/// 自动隐藏密码框

src/ComputerLock/Platforms/SystemKeyHook.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class SystemKeyHook : WindowsInputHook
1212

1313
public event EventHandler? OnUserInput;
1414

15-
public void SetIgnoreHotkey(Hotkey hotKey)
15+
public void SetIgnoreHotkey(Hotkey? hotKey)
1616
{
1717
_ignoreHotkey = hotKey;
1818
}

src/ComputerLock/Resources/Lang.Designer.cs

Lines changed: 13 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ComputerLock/Resources/Lang.en.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,4 +429,7 @@
429429
<data name="NetworkRequestFailed" xml:space="preserve">
430430
<value>Network request failed.</value>
431431
</data>
432+
<data name="DisablePasswordBoxTips" xml:space="preserve">
433+
<value>Unlock method: Press [ESC] key or click with mouse to show password box</value>
434+
</data>
432435
</root>

src/ComputerLock/Resources/Lang.resx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@
145145
<value>按下 ESC 键显示密码框</value>
146146
</data>
147147
<data name="MouseDownActivePwd" xml:space="preserve">
148-
<value>鼠标点击密码框位置时显示</value>
148+
<value>点击屏幕上设置的密码框位置显示密码框</value>
149149
</data>
150150
<data name="ActiveMethodEmpty" xml:space="preserve">
151151
<value>至少需要为密码框启用一种激活方式</value>
152152
</data>
153153
<data name="PwdLocation" xml:space="preserve">
154-
<value>密码框位置</value>
154+
<value>密码框在主屏幕中的位置</value>
155155
</data>
156156
<data name="TopLeft" xml:space="preserve">
157157
<value>左上</value>
@@ -235,13 +235,13 @@
235235
<value>锁定和解锁时显示动画</value>
236236
</data>
237237
<data name="EnablePasswordBox" xml:space="preserve">
238-
<value>显示密码框</value>
238+
<value>显示解锁密码框</value>
239239
</data>
240240
<data name="UnLocked" xml:space="preserve">
241241
<value>已解锁</value>
242242
</data>
243243
<data name="EnablePasswordBoxTips" xml:space="preserve">
244-
<value>锁屏状态下,先按 ESC 键,然后输入密码即可解锁</value>
244+
<value>解锁方式:按 [ESC] 键,然后直接输入密码</value>
245245
</data>
246246
<data name="LogFiles" xml:space="preserve">
247247
<value>日志文件</value>
@@ -429,4 +429,7 @@
429429
<data name="NetworkRequestFailed" xml:space="preserve">
430430
<value>网络请求失败,请稍后再试。</value>
431431
</data>
432+
<data name="DisablePasswordBoxTips" xml:space="preserve">
433+
<value>解锁方式:按 [ESC] 键 或 鼠标点击密码框位置显示密码框</value>
434+
</data>
432435
</root>

src/ComputerLock/Resources/Lang.zh.resx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@
145145
<value>按下 ESC 键显示密码框</value>
146146
</data>
147147
<data name="MouseDownActivePwd" xml:space="preserve">
148-
<value>鼠标点击密码框位置时显示</value>
148+
<value>点击屏幕上设置的密码框位置显示密码框</value>
149149
</data>
150150
<data name="ActiveMethodEmpty" xml:space="preserve">
151151
<value>至少需要为密码框启用一种激活方式</value>
152152
</data>
153153
<data name="PwdLocation" xml:space="preserve">
154-
<value>密码框位置</value>
154+
<value>密码框在主屏幕中的位置</value>
155155
</data>
156156
<data name="TopLeft" xml:space="preserve">
157157
<value>左上</value>
@@ -235,13 +235,13 @@
235235
<value>锁定和解锁时显示动画</value>
236236
</data>
237237
<data name="EnablePasswordBox" xml:space="preserve">
238-
<value>显示密码框</value>
238+
<value>显示解锁密码框</value>
239239
</data>
240240
<data name="UnLocked" xml:space="preserve">
241241
<value>已解锁</value>
242242
</data>
243243
<data name="EnablePasswordBoxTips" xml:space="preserve">
244-
<value>锁屏状态下,先按 ESC 键,然后输入密码即可解锁</value>
244+
<value>解锁方式:按 [ESC] 键,然后直接输入密码</value>
245245
</data>
246246
<data name="LogFiles" xml:space="preserve">
247247
<value>日志文件</value>
@@ -429,4 +429,7 @@
429429
<data name="NetworkRequestFailed" xml:space="preserve">
430430
<value>网络请求失败,请稍后再试。</value>
431431
</data>
432+
<data name="DisablePasswordBoxTips" xml:space="preserve">
433+
<value>解锁方式:按 [ESC] 键 或 鼠标点击密码框位置显示密码框</value>
434+
</data>
432435
</root>

src/ComputerLock/Services/GlobalLockService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ public void Lock()
218218
}
219219
}
220220
}
221+
else if (_appSettings.ScreenUnlockMethod == ScreenUnlockMethods.Password)
222+
{
223+
_logger.Info("全局锁定 -> 密码解锁,准备放行非系统按键");
224+
_systemKeyHook.SetIgnoreHotkey(null);
225+
}
221226
_systemKeyHook.InstallHook();
222227

223228
if (_appSettings.IsDisableWindowsLock)

0 commit comments

Comments
 (0)