diff --git a/Ink Canvas/Helpers/SecurityManager.cs b/Ink Canvas/Helpers/SecurityManager.cs
index db501d7b..23383cee 100644
--- a/Ink Canvas/Helpers/SecurityManager.cs
+++ b/Ink Canvas/Helpers/SecurityManager.cs
@@ -57,6 +57,16 @@ namespace Ink_Canvas.Helpers
public static bool IsPasswordRequiredForResetConfig(Settings settings)
=> IsPasswordFeatureEnabled(settings) && HasPasswordConfigured(settings) && settings.Security.RequirePasswordOnResetConfig;
+ ///
+ /// 指示在修改或清空点名名单前是否需要输入安全密码。
+ ///
+ /// 应用设置对象。
+ /// 当已启用密码功能、已配置密码且开启了对应开关时返回 true;否则返回 false。
+ public static bool IsPasswordRequiredForModifyOrClearNameList(Settings settings)
+ => IsPasswordFeatureEnabled(settings)
+ && HasPasswordConfigured(settings)
+ && settings.Security.RequirePasswordOnModifyOrClearNameList;
+
///
/// 将提供的明文密码与 Settings 中存储的密码散列进行比对以验证密码是否正确。
///
diff --git a/Ink Canvas/Resources/Settings.cs b/Ink Canvas/Resources/Settings.cs
index d2a9ebd8..334263ce 100644
--- a/Ink Canvas/Resources/Settings.cs
+++ b/Ink Canvas/Resources/Settings.cs
@@ -53,6 +53,8 @@ namespace Ink_Canvas
public bool RequirePasswordOnEnterSettings { get; set; } = false;
[JsonProperty("requirePasswordOnResetConfig")]
public bool RequirePasswordOnResetConfig { get; set; } = false;
+ [JsonProperty("requirePasswordOnModifyOrClearNameList")]
+ public bool RequirePasswordOnModifyOrClearNameList { get; set; } = false;
[JsonProperty("enableProcessProtection")]
public bool EnableProcessProtection { get; set; } = true;
}
diff --git a/Ink Canvas/Windows/NewStyleRollCallWindow.xaml.cs b/Ink Canvas/Windows/NewStyleRollCallWindow.xaml.cs
index 54880fb3..ae442f2b 100644
--- a/Ink Canvas/Windows/NewStyleRollCallWindow.xaml.cs
+++ b/Ink Canvas/Windows/NewStyleRollCallWindow.xaml.cs
@@ -1,4 +1,4 @@
-using Ink_Canvas.Helpers;
+using Ink_Canvas.Helpers;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@@ -1200,10 +1200,19 @@ namespace Ink_Canvas
UpdateCountDisplay();
}
- private void ImportList_Click(object sender, RoutedEventArgs e)
+ private async void ImportList_Click(object sender, RoutedEventArgs e)
{
try
{
+ if (SecurityManager.IsPasswordRequiredForModifyOrClearNameList(MainWindow.Settings))
+ {
+ bool ok = await SecurityManager.PromptAndVerifyAsync(
+ MainWindow.Settings,
+ this,
+ "名单修改验证",
+ "请输入安全密码以修改点名名单。");
+ if (!ok) return;
+ }
// 打开名单导入窗口,与老点名UI保持一致
var namesInputWindow = new NamesInputWindow();
namesInputWindow.ShowDialog();
@@ -1260,10 +1269,19 @@ namespace Ink_Canvas
}
}
- private void ClearList_Click(object sender, RoutedEventArgs e)
+ private async void ClearList_Click(object sender, RoutedEventArgs e)
{
try
{
+ if (SecurityManager.IsPasswordRequiredForModifyOrClearNameList(MainWindow.Settings))
+ {
+ bool ok = await SecurityManager.PromptAndVerifyAsync(
+ MainWindow.Settings,
+ this,
+ "名单清空验证",
+ "请输入安全密码以清空点名名单。");
+ if (!ok) return;
+ }
// 清空名单
nameList.Clear();
UpdateListCountDisplay();
diff --git a/Ink Canvas/Windows/RandWindow.xaml.cs b/Ink Canvas/Windows/RandWindow.xaml.cs
index 867e9664..e0839716 100644
--- a/Ink Canvas/Windows/RandWindow.xaml.cs
+++ b/Ink Canvas/Windows/RandWindow.xaml.cs
@@ -390,8 +390,18 @@ namespace Ink_Canvas
}
}
- private void BorderBtnHelp_MouseUp(object sender, MouseButtonEventArgs e)
+ private async void BorderBtnHelp_MouseUp(object sender, MouseButtonEventArgs e)
{
+ if (SecurityManager.IsPasswordRequiredForModifyOrClearNameList(MainWindow.Settings))
+ {
+ bool ok = await SecurityManager.PromptAndVerifyAsync(
+ MainWindow.Settings,
+ this,
+ "名单修改验证",
+ "请输入安全密码以修改点名名单。");
+ if (!ok) return;
+ }
+
new NamesInputWindow().ShowDialog();
Window_Loaded(this, null);
}
diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml b/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml
index 9d5a199c..cfb9c7d1 100644
--- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml
+++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml
@@ -116,6 +116,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -144,4 +158,3 @@
-
diff --git a/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml.cs b/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml.cs
index d3a9576f..3b5309c9 100644
--- a/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml.cs
+++ b/Ink Canvas/Windows/SettingsViews/SettingsViews/SecurityPanel.xaml.cs
@@ -35,6 +35,7 @@ namespace Ink_Canvas.Windows.SettingsViews
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnExit"), sec.RequirePasswordOnExit);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnEnterSettings"), sec.RequirePasswordOnEnterSettings);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnResetConfig"), sec.RequirePasswordOnResetConfig);
+ SetToggleSwitchState(FindToggleSwitch("ToggleSwitchRequirePasswordOnModifyOrClearNameList"), sec.RequirePasswordOnModifyOrClearNameList);
SetToggleSwitchState(FindToggleSwitch("ToggleSwitchEnableProcessProtection"), sec.EnableProcessProtection);
UpdatePasswordUiState();
@@ -65,9 +66,11 @@ namespace Ink_Canvas.Windows.SettingsViews
var t1 = FindToggleSwitch("ToggleSwitchRequirePasswordOnExit");
var t2 = FindToggleSwitch("ToggleSwitchRequirePasswordOnEnterSettings");
var t3 = FindToggleSwitch("ToggleSwitchRequirePasswordOnResetConfig");
+ var t4 = FindToggleSwitch("ToggleSwitchRequirePasswordOnModifyOrClearNameList");
if (t1 != null) t1.IsEnabled = usageEnabled;
if (t2 != null) t2.IsEnabled = usageEnabled;
if (t3 != null) t3.IsEnabled = usageEnabled;
+ if (t4 != null) t4.IsEnabled = usageEnabled;
}
///
@@ -143,6 +146,10 @@ namespace Ink_Canvas.Windows.SettingsViews
sec.RequirePasswordOnResetConfig = newState;
MainWindow.SaveSettingsToFile();
break;
+ case "RequirePasswordOnModifyOrClearNameList":
+ sec.RequirePasswordOnModifyOrClearNameList = newState;
+ MainWindow.SaveSettingsToFile();
+ break;
case "EnableProcessProtection":
sec.EnableProcessProtection = newState;
MainWindow.SaveSettingsToFile();