From b9cd25b511cad9a7f7aab9948536394f289a8fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=9C=E8=8A=B8=E5=BC=9F=E5=BC=9F?= Date: Sat, 28 Mar 2026 13:14:06 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=AE=80=E5=8C=96=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E6=A1=86=E6=9E=B6=E9=85=8D=E7=BD=AE=E5=B9=B6=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E8=84=9A=E6=9C=AC=E9=97=AE=E9=A2=98=E5=92=8C?= =?UTF-8?q?=E5=90=AF=E7=94=A8=E6=B7=B1=E8=89=B2=E6=A8=A1=E5=BC=8F=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContextMenuManager/App.xaml | 2 +- ContextMenuManager/App.xaml.cs | 6 +++++- ContextMenuManager/ContextMenuManager.csproj | 10 +++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ContextMenuManager/App.xaml b/ContextMenuManager/App.xaml index 0c16b386..15b2fec4 100644 --- a/ContextMenuManager/App.xaml +++ b/ContextMenuManager/App.xaml @@ -1,4 +1,4 @@ - - net10.0-windows10.0.19041.0 + net10.0-windows WinExe true true @@ -55,16 +55,12 @@ - + - From 197576bee7a9fdbb97100f2ee87933db52f5e1ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=9C=E8=8A=B8=E5=BC=9F=E5=BC=9F?= Date: Sat, 28 Mar 2026 13:21:07 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContextMenuManager/App.xaml.cs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ContextMenuManager/App.xaml.cs b/ContextMenuManager/App.xaml.cs index 479e9a17..cb1c39ea 100644 --- a/ContextMenuManager/App.xaml.cs +++ b/ContextMenuManager/App.xaml.cs @@ -1,6 +1,7 @@ using ContextMenuManager.Methods; using iNKORE.UI.WPF.Modern; using iNKORE.UI.WPF.Modern.Common; +using Microsoft.Win32; using System; using System.Diagnostics; using System.Text; @@ -26,8 +27,9 @@ protected override void OnStartup(StartupEventArgs e) { Current.ShutdownMode = ShutdownMode.OnMainWindowClose; - // 初始化主题管理器,使用系统主题设置 - ThemeManager.Current.ApplicationTheme = ApplicationTheme.Dark; + // 初始化主题管理器,根据系统主题设置应用主题 + var isDarkMode = IsSystemDarkModeEnabled(); + ThemeManager.Current.ApplicationTheme = isDarkMode ? ApplicationTheme.Dark : ApplicationTheme.Light; RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); @@ -112,5 +114,29 @@ public void OnSecondAppStarted() Current?.MainWindow.Show(); Current?.MainWindow.Focus(); } + + /// + /// 检测系统是否启用深色模式 + /// + private static bool IsSystemDarkModeEnabled() + { + try + { + using var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"); + if (key != null) + { + var value = key.GetValue("AppsUseLightTheme"); + if (value is int intValue) + { + return intValue == 0; // 0 = Dark mode, 1 = Light mode + } + } + } + catch + { + // 如果读取注册表失败,默认使用浅色模式 + } + return false; // 默认浅色模式 + } } } From ac6838966610dbdde5f33ab8962cea39da949e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=9C=E8=8A=B8=E5=BC=9F=E5=BC=9F?= Date: Sun, 29 Mar 2026 10:09:31 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=B7=9F=E9=9A=8F=E7=B3=BB=E7=BB=9F=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=8F=98=E5=8C=96=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContextMenuManager/App.xaml.cs | 23 ++++++++++++++++++-- ContextMenuManager/ContextMenuManager.csproj | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ContextMenuManager/App.xaml.cs b/ContextMenuManager/App.xaml.cs index cb1c39ea..b62903c5 100644 --- a/ContextMenuManager/App.xaml.cs +++ b/ContextMenuManager/App.xaml.cs @@ -28,8 +28,10 @@ protected override void OnStartup(StartupEventArgs e) Current.ShutdownMode = ShutdownMode.OnMainWindowClose; // 初始化主题管理器,根据系统主题设置应用主题 - var isDarkMode = IsSystemDarkModeEnabled(); - ThemeManager.Current.ApplicationTheme = isDarkMode ? ApplicationTheme.Dark : ApplicationTheme.Light; + UpdateApplicationTheme(); + + // 监听系统主题变化 + SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged; RegisterAppDomainExceptions(); RegisterDispatcherUnhandledException(); @@ -45,6 +47,20 @@ protected override void OnStartup(StartupEventArgs e) Updater.PeriodicUpdate(); } + private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e) + { + if (e.Category == UserPreferenceCategory.General) + { + UpdateApplicationTheme(); + } + } + + private static void UpdateApplicationTheme() + { + var isDarkMode = IsSystemDarkModeEnabled(); + ThemeManager.Current.ApplicationTheme = isDarkMode ? ApplicationTheme.Dark : ApplicationTheme.Light; + } + private void RegisterExitEvents() { AppDomain.CurrentDomain.ProcessExit += (s, e) => @@ -99,6 +115,9 @@ protected virtual void Dispose(bool disposing) _disposed = true; } + // 取消注册系统主题变化监听器 + SystemEvents.UserPreferenceChanged -= SystemEvents_UserPreferenceChanged; + AppConfig.CleanDirectory(); } diff --git a/ContextMenuManager/ContextMenuManager.csproj b/ContextMenuManager/ContextMenuManager.csproj index e36f91ae..70f1a186 100644 --- a/ContextMenuManager/ContextMenuManager.csproj +++ b/ContextMenuManager/ContextMenuManager.csproj @@ -73,4 +73,4 @@ - + \ No newline at end of file From 8da07eb86806cc1ef155c22a2abb9b44e00cb5e5 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 29 Mar 2026 10:20:26 +0800 Subject: [PATCH 4/5] Update language file copy logic in project build Changed LanguageFiles to source from the solution's Languages directory and added a Copy task to ensure all language files are copied to the output Config\Languages directory during the build process. This ensures language resources are consistently available in the build output. --- ContextMenuManager/ContextMenuManager.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ContextMenuManager/ContextMenuManager.csproj b/ContextMenuManager/ContextMenuManager.csproj index 70f1a186..5708a872 100644 --- a/ContextMenuManager/ContextMenuManager.csproj +++ b/ContextMenuManager/ContextMenuManager.csproj @@ -59,8 +59,12 @@ OverwriteReadOnlyFiles="true" /> - + + From c32f5e0858532f0a225f7a04c03bb5d1f77be8fb Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 29 Mar 2026 10:22:25 +0800 Subject: [PATCH 5/5] Simplify output path and update target framework Removed target framework from output path by setting AppendTargetFrameworkToOutputPath to false. Updated pipeline script to use new DLL location. Changed publish profile target framework to net10.0-windows for consistency and compatibility. --- .github/workflows/publish.yml | 2 +- ContextMenuManager/ContextMenuManager.csproj | 1 + .../Properties/PublishProfiles/Net10.0-Win64.pubxml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ae30de0c..28738cc2 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -42,7 +42,7 @@ jobs: # Get package version - name: Get Package Version run: | - $version = [system.diagnostics.fileversioninfo]::getversioninfo("ContextMenuManager\bin\Release\net10.0-windows10.0.19041.0\ContextMenuManager.dll").fileversion + $version = [system.diagnostics.fileversioninfo]::getversioninfo("ContextMenuManager\bin\Release\ContextMenuManager.dll").fileversion echo "release_version=$version" | out-file -filepath $env:github_env -encoding utf-8 -append # Publish the project diff --git a/ContextMenuManager/ContextMenuManager.csproj b/ContextMenuManager/ContextMenuManager.csproj index 5708a872..c36e374f 100644 --- a/ContextMenuManager/ContextMenuManager.csproj +++ b/ContextMenuManager/ContextMenuManager.csproj @@ -11,6 +11,7 @@ $(NoWarn);WFO1000;CA1416 true false + false diff --git a/ContextMenuManager/Properties/PublishProfiles/Net10.0-Win64.pubxml b/ContextMenuManager/Properties/PublishProfiles/Net10.0-Win64.pubxml index 5b8dfadd..b1ac9576 100644 --- a/ContextMenuManager/Properties/PublishProfiles/Net10.0-Win64.pubxml +++ b/ContextMenuManager/Properties/PublishProfiles/Net10.0-Win64.pubxml @@ -7,7 +7,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. FileSystem Release Any CPU - net10.0-windows10.0.19041.0 + net10.0-windows bin\Publish\ win-x64 false