From 4ce65f98c524ec66aa7433b32eda227399ee73da Mon Sep 17 00:00:00 2001 From: diann34 Date: Tue, 2 Jun 2026 19:12:04 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat(manifest):=E5=9C=A8=E6=B8=85=E5=8D=95?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E6=B7=BB=E5=8A=A0supportedOSPlatfor?= =?UTF-8?q?ms=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/manifest.yml b/manifest.yml index 7e001d84..7b3d7772 100644 --- a/manifest.yml +++ b/manifest.yml @@ -16,3 +16,5 @@ icon: icon.png repoOwner: Programmer-MrWang repoName: SystemTools assetsRoot: main +supportedOSPlatforms: +- Windows \ No newline at end of file From e8de8b3570809e7588363e4d901f47999d8800a4 Mon Sep 17 00:00:00 2001 From: Nikoa Date: Fri, 5 Jun 2026 07:11:56 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=E4=BD=BF=E7=94=A8API=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E6=9B=BF=E8=B0=83=E7=94=A8shutdown=E5=B7=A5?= =?UTF-8?q?=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Actions/ImmediateRestartAction.cs | 47 ++++++++++++++++++++---------- Actions/ImmediateShutdownAction.cs | 47 ++++++++++++++++++++---------- NativeMethods.txt | 3 +- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/Actions/ImmediateRestartAction.cs b/Actions/ImmediateRestartAction.cs index bfa3183e..a18a2070 100644 --- a/Actions/ImmediateRestartAction.cs +++ b/Actions/ImmediateRestartAction.cs @@ -3,7 +3,9 @@ using Microsoft.Extensions.Logging; using System; using System.Diagnostics; +using System.Runtime.InteropServices; using System.Threading.Tasks; +using Windows.Win32; namespace SystemTools.Actions; @@ -11,30 +13,43 @@ namespace SystemTools.Actions; public class ImmediateRestartAction(ILogger logger) : ActionBase { private readonly ILogger _logger = logger; - + [DllImport("ntdll.dll", EntryPoint = "RtlAdjustPrivilege")] // 此API无法使用CsWin32包生成,因为这是个不公开的函数 + internal static extern uint W32_RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue); + internal const int SE_SHUTDOWN_PRIVILEGE = 19; protected override async Task OnInvoke() { _logger.LogDebug("ImmediateRestartAction OnInvoke 开始"); - try + if(W32_RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, false, out _) != 0x00000000) // STATUS_SUCCESS { - var psi = new ProcessStartInfo - { - FileName = "shutdown", - Arguments = "-r -t 0", - UseShellExecute = false, - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden - }; - - Process.Start(psi); - _logger.LogInformation("已执行立即重启命令"); + _logger.LogError("执行立即重启失败:获取关机权限失败"); + throw new InvalidOperationException("执行立即重启失败"); } - catch (Exception ex) + if(!PInvoke.ExitWindowsEx(Windows.Win32.System.Shutdown.EXIT_WINDOWS_FLAGS.EWX_REBOOT,Windows.Win32.System.Shutdown.SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED)) { - _logger.LogError(ex, "执行立即重启失败"); - throw; + _logger.LogError("执行立即重启失败"); + throw new InvalidOperationException("执行立即重启失败"); } + else { _logger.LogInformation("已执行立即重启命令"); } + //try + //{ + // var psi = new ProcessStartInfo + // { + // FileName = "shutdown", + // Arguments = "-r -t 0", + // UseShellExecute = false, + // CreateNoWindow = true, + // WindowStyle = ProcessWindowStyle.Hidden + // }; + + // Process.Start(psi); + // _logger.LogInformation("已执行立即重启命令"); + //} + //catch (Exception ex) + //{ + // _logger.LogError(ex, "执行立即重启失败"); + // throw; + //} await base.OnInvoke(); _logger.LogDebug("ImmediateRestartAction OnInvoke 完成"); diff --git a/Actions/ImmediateShutdownAction.cs b/Actions/ImmediateShutdownAction.cs index d22ebef4..6bcf1461 100644 --- a/Actions/ImmediateShutdownAction.cs +++ b/Actions/ImmediateShutdownAction.cs @@ -3,7 +3,9 @@ using Microsoft.Extensions.Logging; using System; using System.Diagnostics; +using System.Runtime.InteropServices; using System.Threading.Tasks; +using Windows.Win32; namespace SystemTools.Actions; @@ -11,30 +13,43 @@ namespace SystemTools.Actions; public class ImmediateShutdownAction(ILogger logger) : ActionBase { private readonly ILogger _logger = logger; - + [DllImport("ntdll.dll", EntryPoint = "RtlAdjustPrivilege")] // 此API无法使用CsWin32包生成,因为这是个不公开的函数 + internal static extern uint W32_RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue); + internal const int SE_SHUTDOWN_PRIVILEGE = 19; protected override async Task OnInvoke() { _logger.LogDebug("ImmediateShutdownAction OnInvoke 开始"); - try + if (W32_RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, true, false, out _) != 0x00000000) // STATUS_SUCCESS { - var psi = new ProcessStartInfo - { - FileName = "shutdown", - Arguments = "-s -t 0", - UseShellExecute = false, - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden - }; - - Process.Start(psi); - _logger.LogInformation("已执行立即关机命令"); + _logger.LogError("执行立即关机失败:获取关机权限失败"); + throw new InvalidOperationException("执行立即关机失败"); } - catch (Exception ex) + if (!PInvoke.ExitWindowsEx(Windows.Win32.System.Shutdown.EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN, Windows.Win32.System.Shutdown.SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED)) { - _logger.LogError(ex, "执行立即关机失败"); - throw; + _logger.LogError("执行立即关机失败"); + throw new InvalidOperationException("执行立即关机失败"); } + else { _logger.LogInformation("已执行立即关机命令"); } + //try + //{ + // var psi = new ProcessStartInfo + // { + // FileName = "shutdown", + // Arguments = "-s -t 0", + // UseShellExecute = false, + // CreateNoWindow = true, + // WindowStyle = ProcessWindowStyle.Hidden + // }; + + // Process.Start(psi); + // _logger.LogInformation("已执行立即关机命令"); + //} + //catch (Exception ex) + //{ + // _logger.LogError(ex, "执行立即关机失败"); + // throw; + //} await base.OnInvoke(); _logger.LogDebug("ImmediateShutdownAction OnInvoke 完成"); diff --git a/NativeMethods.txt b/NativeMethods.txt index 985f2ae1..559355dc 100644 --- a/NativeMethods.txt +++ b/NativeMethods.txt @@ -35,4 +35,5 @@ EnumWindows GetClassName GetWindowText DEV_BROADCAST_DEVICEINTERFACE_W -DEV_BROADCAST_HDR \ No newline at end of file +DEV_BROADCAST_HDR +ExitWindowsEx \ No newline at end of file From bc8fd30c86c1bbc7e4bf06742bd87690b6a14866 Mon Sep 17 00:00:00 2001 From: Nikoa Date: Fri, 5 Jun 2026 07:47:02 +0800 Subject: [PATCH 3/6] =?UTF-8?q?feat:=E6=B7=BB=E5=8A=A0=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E6=92=AD=E6=8A=A5=E8=A1=8C=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Actions/DoSpeechAction.cs | 34 +++++++++++++++++ Controls/DoSpeechSettingsControl.cs | 40 ++++++++++++++++++++ Plugin.cs | 6 ++- Settings/DoSpeechSettings.cs | 9 +++++ SettingsPage/SystemToolsSettingsViewModel.cs | 1 + 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Actions/DoSpeechAction.cs create mode 100644 Controls/DoSpeechSettingsControl.cs create mode 100644 Settings/DoSpeechSettings.cs diff --git a/Actions/DoSpeechAction.cs b/Actions/DoSpeechAction.cs new file mode 100644 index 00000000..0150a570 --- /dev/null +++ b/Actions/DoSpeechAction.cs @@ -0,0 +1,34 @@ +using ClassIsland.Core.Abstractions.Automation; +using ClassIsland.Core.Abstractions.Services.SpeechService; +using ClassIsland.Core.Attributes; +using Microsoft.Extensions.Logging; +using System; +using System.Threading.Tasks; +using SystemTools.Settings; + +namespace SystemTools.Actions +{ + [ActionInfo("SystemTools.DoSpeech", "语音播报", "\uE5C7", false)] + public class DoSpeechAction(ILogger logger, ISpeechService speechService) : ActionBase + { + private readonly ILogger _logger = logger; + private readonly ISpeechService _speechService = speechService; + + protected override async Task OnInvoke() + { + _logger.LogDebug("DoSpeechAction OnInvoke 开始"); + var text = Settings?.Text; + if (string.IsNullOrWhiteSpace(text)) + { + _logger.LogError("语音播报内容不能为空"); + throw new InvalidOperationException("语音播报内容不能为空"); + } + else + { + _speechService.EnqueueSpeechQueue(text); + } + await base.OnInvoke(); + _logger.LogDebug("DoSpeechAction OnInvoke 完成"); + } + } +} diff --git a/Controls/DoSpeechSettingsControl.cs b/Controls/DoSpeechSettingsControl.cs new file mode 100644 index 00000000..ac838b55 --- /dev/null +++ b/Controls/DoSpeechSettingsControl.cs @@ -0,0 +1,40 @@ +using Avalonia.Controls; +using ClassIsland.Core.Abstractions.Controls; +using SystemTools.Settings; + +namespace SystemTools.Controls; + +public class DoSpeechSettingsControl : ActionSettingsControlBase +{ + private readonly TextBox _textBox; + + public DoSpeechSettingsControl() + { + var panel = new StackPanel { Spacing = 8, Margin = new(10) }; + + panel.Children.Add(new TextBlock + { + Text = "语音播报", + FontWeight = Avalonia.Media.FontWeight.Bold, + FontSize = 14 + }); + + _textBox = new TextBox + { + Watermark = "请输入要播报的文字", + AcceptsReturn = true, + Height = 120, + Width = 420 + }; + _textBox.TextChanged += (_, _) => { Settings.Text = _textBox.Text ?? string.Empty; }; + panel.Children.Add(_textBox); + + Content = panel; + } + + protected override void OnInitialized() + { + base.OnInitialized(); + _textBox.Text = Settings.Text; + } +} diff --git a/Plugin.cs b/Plugin.cs index a7e177f7..a965e13e 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -278,6 +278,8 @@ private void RegisterBaseActions(IServiceCollection services) RegisterActionIfEnabled(services, config, "SystemTools.BackgroundPlayAudio"); RegisterActionIfEnabled(services, config, "SystemTools.ShowDesktop"); + // 语音播报 + RegisterActionIfEnabled(services, config, "SystemTools.DoSpeech"); // 悬浮窗设置 if (config.EnableFloatingWindowFeature) @@ -514,7 +516,7 @@ private void BuildBaseActionTree() if (HasAnyActionEnabled(config, "SystemTools.ClearAllNotifications", "SystemTools.RestartAsAdmin", "SystemTools.LoadTemporaryClassPlan", "SystemTools.OpenAppSettings", - "SystemTools.OpenProfileEditor", "SystemTools.OpenClassSwapWindow")) + "SystemTools.OpenProfileEditor", "SystemTools.OpenClassSwapWindow","SystemTools.DoSpeech")) { IActionService.ActionMenuTree["SystemTools 行动"].Add(new ActionMenuTreeGroup("ClassIsland…", "\uE5CB")); BuildClassIslandMenu(config); @@ -861,6 +863,8 @@ private void BuildClassIslandMenu(MainConfigData config) items.Add(new ActionMenuTreeItem("SystemTools.OpenProfileEditor", "打开档案编辑", "\uE699")); if (config.IsActionEnabled("SystemTools.OpenClassSwapWindow")) items.Add(new ActionMenuTreeItem("SystemTools.OpenClassSwapWindow", "打开换课窗口", "\uE13B")); + if (config.IsActionEnabled("SystemTools.DoSpeech")) + items.Add(new ActionMenuTreeItem("SystemTools.DoSpeech", "语音播报", "\uE5C7")); if (items.Count > 0) { diff --git a/Settings/DoSpeechSettings.cs b/Settings/DoSpeechSettings.cs new file mode 100644 index 00000000..d01e980a --- /dev/null +++ b/Settings/DoSpeechSettings.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace SystemTools.Settings; + +public class DoSpeechSettings +{ + [JsonPropertyName("text")] + public string Text { get; set; } = string.Empty; +} diff --git a/SettingsPage/SystemToolsSettingsViewModel.cs b/SettingsPage/SystemToolsSettingsViewModel.cs index 511a9d7a..08a16110 100644 --- a/SettingsPage/SystemToolsSettingsViewModel.cs +++ b/SettingsPage/SystemToolsSettingsViewModel.cs @@ -213,6 +213,7 @@ public void InitializeFeatureItems() ("SystemTools.OpenAppSettings", "打开应用设置", "ClassIsland"), ("SystemTools.OpenProfileEditor", "打开档案编辑", "ClassIsland"), ("SystemTools.OpenClassSwapWindow", "打开换课窗口", "ClassIsland"), + ("SystemTools.DoSpeech", "语音播报", "ClassIsland"), }; if (Settings.EnableFloatingWindowFeature) From 09446ce1e3d135c952017c2c68c9696d712bbb23 Mon Sep 17 00:00:00 2001 From: Nikoa Date: Fri, 5 Jun 2026 08:03:48 +0800 Subject: [PATCH 4/6] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E7=BC=BA=E5=B0=91?= =?UTF-8?q?=E7=9A=84EWX=5FPOWEROFF=20flag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Actions/ImmediateShutdownAction.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Actions/ImmediateShutdownAction.cs b/Actions/ImmediateShutdownAction.cs index 6bcf1461..0f6a0cf4 100644 --- a/Actions/ImmediateShutdownAction.cs +++ b/Actions/ImmediateShutdownAction.cs @@ -25,7 +25,7 @@ protected override async Task OnInvoke() _logger.LogError("执行立即关机失败:获取关机权限失败"); throw new InvalidOperationException("执行立即关机失败"); } - if (!PInvoke.ExitWindowsEx(Windows.Win32.System.Shutdown.EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN, Windows.Win32.System.Shutdown.SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED)) + if (!PInvoke.ExitWindowsEx(Windows.Win32.System.Shutdown.EXIT_WINDOWS_FLAGS.EWX_SHUTDOWN | Windows.Win32.System.Shutdown.EXIT_WINDOWS_FLAGS.EWX_POWEROFF, Windows.Win32.System.Shutdown.SHUTDOWN_REASON.SHTDN_REASON_FLAG_PLANNED)) { _logger.LogError("执行立即关机失败"); throw new InvalidOperationException("执行立即关机失败"); From 17ad8738bba513ad1899609c10588a223a9afca0 Mon Sep 17 00:00:00 2001 From: diann34 Date: Sun, 14 Jun 2026 06:07:43 +0800 Subject: [PATCH 5/6] =?UTF-8?q?Revert=20"feat:=E6=B7=BB=E5=8A=A0=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=92=AD=E6=8A=A5=E8=A1=8C=E5=8A=A8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit bc8fd30c86c1bbc7e4bf06742bd87690b6a14866. --- Actions/DoSpeechAction.cs | 34 ----------------- Controls/DoSpeechSettingsControl.cs | 40 -------------------- Plugin.cs | 6 +-- Settings/DoSpeechSettings.cs | 9 ----- SettingsPage/SystemToolsSettingsViewModel.cs | 1 - 5 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 Actions/DoSpeechAction.cs delete mode 100644 Controls/DoSpeechSettingsControl.cs delete mode 100644 Settings/DoSpeechSettings.cs diff --git a/Actions/DoSpeechAction.cs b/Actions/DoSpeechAction.cs deleted file mode 100644 index 0150a570..00000000 --- a/Actions/DoSpeechAction.cs +++ /dev/null @@ -1,34 +0,0 @@ -using ClassIsland.Core.Abstractions.Automation; -using ClassIsland.Core.Abstractions.Services.SpeechService; -using ClassIsland.Core.Attributes; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; -using SystemTools.Settings; - -namespace SystemTools.Actions -{ - [ActionInfo("SystemTools.DoSpeech", "语音播报", "\uE5C7", false)] - public class DoSpeechAction(ILogger logger, ISpeechService speechService) : ActionBase - { - private readonly ILogger _logger = logger; - private readonly ISpeechService _speechService = speechService; - - protected override async Task OnInvoke() - { - _logger.LogDebug("DoSpeechAction OnInvoke 开始"); - var text = Settings?.Text; - if (string.IsNullOrWhiteSpace(text)) - { - _logger.LogError("语音播报内容不能为空"); - throw new InvalidOperationException("语音播报内容不能为空"); - } - else - { - _speechService.EnqueueSpeechQueue(text); - } - await base.OnInvoke(); - _logger.LogDebug("DoSpeechAction OnInvoke 完成"); - } - } -} diff --git a/Controls/DoSpeechSettingsControl.cs b/Controls/DoSpeechSettingsControl.cs deleted file mode 100644 index ac838b55..00000000 --- a/Controls/DoSpeechSettingsControl.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Avalonia.Controls; -using ClassIsland.Core.Abstractions.Controls; -using SystemTools.Settings; - -namespace SystemTools.Controls; - -public class DoSpeechSettingsControl : ActionSettingsControlBase -{ - private readonly TextBox _textBox; - - public DoSpeechSettingsControl() - { - var panel = new StackPanel { Spacing = 8, Margin = new(10) }; - - panel.Children.Add(new TextBlock - { - Text = "语音播报", - FontWeight = Avalonia.Media.FontWeight.Bold, - FontSize = 14 - }); - - _textBox = new TextBox - { - Watermark = "请输入要播报的文字", - AcceptsReturn = true, - Height = 120, - Width = 420 - }; - _textBox.TextChanged += (_, _) => { Settings.Text = _textBox.Text ?? string.Empty; }; - panel.Children.Add(_textBox); - - Content = panel; - } - - protected override void OnInitialized() - { - base.OnInitialized(); - _textBox.Text = Settings.Text; - } -} diff --git a/Plugin.cs b/Plugin.cs index a965e13e..a7e177f7 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -278,8 +278,6 @@ private void RegisterBaseActions(IServiceCollection services) RegisterActionIfEnabled(services, config, "SystemTools.BackgroundPlayAudio"); RegisterActionIfEnabled(services, config, "SystemTools.ShowDesktop"); - // 语音播报 - RegisterActionIfEnabled(services, config, "SystemTools.DoSpeech"); // 悬浮窗设置 if (config.EnableFloatingWindowFeature) @@ -516,7 +514,7 @@ private void BuildBaseActionTree() if (HasAnyActionEnabled(config, "SystemTools.ClearAllNotifications", "SystemTools.RestartAsAdmin", "SystemTools.LoadTemporaryClassPlan", "SystemTools.OpenAppSettings", - "SystemTools.OpenProfileEditor", "SystemTools.OpenClassSwapWindow","SystemTools.DoSpeech")) + "SystemTools.OpenProfileEditor", "SystemTools.OpenClassSwapWindow")) { IActionService.ActionMenuTree["SystemTools 行动"].Add(new ActionMenuTreeGroup("ClassIsland…", "\uE5CB")); BuildClassIslandMenu(config); @@ -863,8 +861,6 @@ private void BuildClassIslandMenu(MainConfigData config) items.Add(new ActionMenuTreeItem("SystemTools.OpenProfileEditor", "打开档案编辑", "\uE699")); if (config.IsActionEnabled("SystemTools.OpenClassSwapWindow")) items.Add(new ActionMenuTreeItem("SystemTools.OpenClassSwapWindow", "打开换课窗口", "\uE13B")); - if (config.IsActionEnabled("SystemTools.DoSpeech")) - items.Add(new ActionMenuTreeItem("SystemTools.DoSpeech", "语音播报", "\uE5C7")); if (items.Count > 0) { diff --git a/Settings/DoSpeechSettings.cs b/Settings/DoSpeechSettings.cs deleted file mode 100644 index d01e980a..00000000 --- a/Settings/DoSpeechSettings.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Text.Json.Serialization; - -namespace SystemTools.Settings; - -public class DoSpeechSettings -{ - [JsonPropertyName("text")] - public string Text { get; set; } = string.Empty; -} diff --git a/SettingsPage/SystemToolsSettingsViewModel.cs b/SettingsPage/SystemToolsSettingsViewModel.cs index 08a16110..511a9d7a 100644 --- a/SettingsPage/SystemToolsSettingsViewModel.cs +++ b/SettingsPage/SystemToolsSettingsViewModel.cs @@ -213,7 +213,6 @@ public void InitializeFeatureItems() ("SystemTools.OpenAppSettings", "打开应用设置", "ClassIsland"), ("SystemTools.OpenProfileEditor", "打开档案编辑", "ClassIsland"), ("SystemTools.OpenClassSwapWindow", "打开换课窗口", "ClassIsland"), - ("SystemTools.DoSpeech", "语音播报", "ClassIsland"), }; if (Settings.EnableFloatingWindowFeature) From be2b75b3d536165ccaa9c3426406a66f16e9833d Mon Sep 17 00:00:00 2001 From: diann34 Date: Sun, 14 Jun 2026 06:10:23 +0800 Subject: [PATCH 6/6] =?UTF-8?q?Revert=20"feat:=E6=B7=BB=E5=8A=A0=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E6=92=AD=E6=8A=A5=E8=A1=8C=E5=8A=A8"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit bc8fd30c86c1bbc7e4bf06742bd87690b6a14866. --- Actions/DoSpeechAction.cs | 34 ----------------- Controls/DoSpeechSettingsControl.cs | 40 -------------------- Plugin.cs | 6 +-- Settings/DoSpeechSettings.cs | 9 ----- SettingsPage/SystemToolsSettingsViewModel.cs | 1 - 5 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 Actions/DoSpeechAction.cs delete mode 100644 Controls/DoSpeechSettingsControl.cs delete mode 100644 Settings/DoSpeechSettings.cs diff --git a/Actions/DoSpeechAction.cs b/Actions/DoSpeechAction.cs deleted file mode 100644 index 0150a570..00000000 --- a/Actions/DoSpeechAction.cs +++ /dev/null @@ -1,34 +0,0 @@ -using ClassIsland.Core.Abstractions.Automation; -using ClassIsland.Core.Abstractions.Services.SpeechService; -using ClassIsland.Core.Attributes; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; -using SystemTools.Settings; - -namespace SystemTools.Actions -{ - [ActionInfo("SystemTools.DoSpeech", "语音播报", "\uE5C7", false)] - public class DoSpeechAction(ILogger logger, ISpeechService speechService) : ActionBase - { - private readonly ILogger _logger = logger; - private readonly ISpeechService _speechService = speechService; - - protected override async Task OnInvoke() - { - _logger.LogDebug("DoSpeechAction OnInvoke 开始"); - var text = Settings?.Text; - if (string.IsNullOrWhiteSpace(text)) - { - _logger.LogError("语音播报内容不能为空"); - throw new InvalidOperationException("语音播报内容不能为空"); - } - else - { - _speechService.EnqueueSpeechQueue(text); - } - await base.OnInvoke(); - _logger.LogDebug("DoSpeechAction OnInvoke 完成"); - } - } -} diff --git a/Controls/DoSpeechSettingsControl.cs b/Controls/DoSpeechSettingsControl.cs deleted file mode 100644 index ac838b55..00000000 --- a/Controls/DoSpeechSettingsControl.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Avalonia.Controls; -using ClassIsland.Core.Abstractions.Controls; -using SystemTools.Settings; - -namespace SystemTools.Controls; - -public class DoSpeechSettingsControl : ActionSettingsControlBase -{ - private readonly TextBox _textBox; - - public DoSpeechSettingsControl() - { - var panel = new StackPanel { Spacing = 8, Margin = new(10) }; - - panel.Children.Add(new TextBlock - { - Text = "语音播报", - FontWeight = Avalonia.Media.FontWeight.Bold, - FontSize = 14 - }); - - _textBox = new TextBox - { - Watermark = "请输入要播报的文字", - AcceptsReturn = true, - Height = 120, - Width = 420 - }; - _textBox.TextChanged += (_, _) => { Settings.Text = _textBox.Text ?? string.Empty; }; - panel.Children.Add(_textBox); - - Content = panel; - } - - protected override void OnInitialized() - { - base.OnInitialized(); - _textBox.Text = Settings.Text; - } -} diff --git a/Plugin.cs b/Plugin.cs index a965e13e..a7e177f7 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -278,8 +278,6 @@ private void RegisterBaseActions(IServiceCollection services) RegisterActionIfEnabled(services, config, "SystemTools.BackgroundPlayAudio"); RegisterActionIfEnabled(services, config, "SystemTools.ShowDesktop"); - // 语音播报 - RegisterActionIfEnabled(services, config, "SystemTools.DoSpeech"); // 悬浮窗设置 if (config.EnableFloatingWindowFeature) @@ -516,7 +514,7 @@ private void BuildBaseActionTree() if (HasAnyActionEnabled(config, "SystemTools.ClearAllNotifications", "SystemTools.RestartAsAdmin", "SystemTools.LoadTemporaryClassPlan", "SystemTools.OpenAppSettings", - "SystemTools.OpenProfileEditor", "SystemTools.OpenClassSwapWindow","SystemTools.DoSpeech")) + "SystemTools.OpenProfileEditor", "SystemTools.OpenClassSwapWindow")) { IActionService.ActionMenuTree["SystemTools 行动"].Add(new ActionMenuTreeGroup("ClassIsland…", "\uE5CB")); BuildClassIslandMenu(config); @@ -863,8 +861,6 @@ private void BuildClassIslandMenu(MainConfigData config) items.Add(new ActionMenuTreeItem("SystemTools.OpenProfileEditor", "打开档案编辑", "\uE699")); if (config.IsActionEnabled("SystemTools.OpenClassSwapWindow")) items.Add(new ActionMenuTreeItem("SystemTools.OpenClassSwapWindow", "打开换课窗口", "\uE13B")); - if (config.IsActionEnabled("SystemTools.DoSpeech")) - items.Add(new ActionMenuTreeItem("SystemTools.DoSpeech", "语音播报", "\uE5C7")); if (items.Count > 0) { diff --git a/Settings/DoSpeechSettings.cs b/Settings/DoSpeechSettings.cs deleted file mode 100644 index d01e980a..00000000 --- a/Settings/DoSpeechSettings.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System.Text.Json.Serialization; - -namespace SystemTools.Settings; - -public class DoSpeechSettings -{ - [JsonPropertyName("text")] - public string Text { get; set; } = string.Empty; -} diff --git a/SettingsPage/SystemToolsSettingsViewModel.cs b/SettingsPage/SystemToolsSettingsViewModel.cs index 08a16110..511a9d7a 100644 --- a/SettingsPage/SystemToolsSettingsViewModel.cs +++ b/SettingsPage/SystemToolsSettingsViewModel.cs @@ -213,7 +213,6 @@ public void InitializeFeatureItems() ("SystemTools.OpenAppSettings", "打开应用设置", "ClassIsland"), ("SystemTools.OpenProfileEditor", "打开档案编辑", "ClassIsland"), ("SystemTools.OpenClassSwapWindow", "打开换课窗口", "ClassIsland"), - ("SystemTools.DoSpeech", "语音播报", "ClassIsland"), }; if (Settings.EnableFloatingWindowFeature)