From 4902559cfae6008def570dde8696798aff6c3da3 Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Thu, 30 Apr 2026 15:38:21 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E5=90=AF=E5=8A=A8=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/App.xaml.cs | 43 ++++++++++++++++++----------------- Ink Canvas/MainWindow.xaml.cs | 10 ++++++-- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Ink Canvas/App.xaml.cs b/Ink Canvas/App.xaml.cs index aab14d96..ce78c510 100644 --- a/Ink Canvas/App.xaml.cs +++ b/Ink Canvas/App.xaml.cs @@ -829,32 +829,11 @@ namespace Ink_Canvas SetSplashProgress(50); } - // 记录应用启动(设备标识符) if (_isSplashScreenShown) { SetSplashMessage("正在加载配置..."); SetSplashProgress(60); - await Task.Delay(100); } - DeviceIdentifier.RecordAppLaunch(); - try - { - var systemVersion = DeviceIdentifier.GetSystemVersion(); - if (!string.IsNullOrWhiteSpace(systemVersion)) - { - SentrySdk.ConfigureScope(scope => - { - scope.SetTag("system_version", systemVersion); - }); - } - } - catch (Exception ex) - { - LogHelper.WriteLogToFile($"App | 初始化系统版本遥测标签失败: {ex.Message}", LogHelper.LogType.Warning); - } - LogHelper.WriteLogToFile($"App | 设备ID: {DeviceIdentifier.GetDeviceId()}"); - LogHelper.WriteLogToFile($"App | 使用频率: {DeviceIdentifier.GetUsageFrequency()}"); - LogHelper.WriteLogToFile($"App | 更新优先级: {DeviceIdentifier.GetUpdatePriority()}"); // 处理更新模式启动 bool isUpdateMode = AutoUpdateHelper.HandleUpdateModeStartup(e.Args); @@ -1288,6 +1267,28 @@ namespace Ink_Canvas { LogHelper.WriteLogToFile(string.Format("加载插件时出错: {0}", ex.Message), LogHelper.LogType.Error); } + + try + { + await Task.Delay(1500); + DeviceIdentifier.RecordAppLaunch(); + var systemVersion = DeviceIdentifier.GetSystemVersion(); + if (!string.IsNullOrWhiteSpace(systemVersion)) + { + SentrySdk.ConfigureScope(scope => + { + scope.SetTag("system_version", systemVersion); + }); + } + + LogHelper.WriteLogToFile($"App | 设备ID: {DeviceIdentifier.GetDeviceId()}"); + LogHelper.WriteLogToFile($"App | 使用频率: {DeviceIdentifier.GetUsageFrequency()}"); + LogHelper.WriteLogToFile($"App | 更新优先级: {DeviceIdentifier.GetUpdatePriority()}"); + } + catch (Exception ex) + { + LogHelper.WriteLogToFile($"App | 初始化设备统计与遥测标签失败: {ex.Message}", LogHelper.LogType.Warning); + } } catch (Exception ex) { diff --git a/Ink Canvas/MainWindow.xaml.cs b/Ink Canvas/MainWindow.xaml.cs index 02bc2a06..7e1cedce 100644 --- a/Ink Canvas/MainWindow.xaml.cs +++ b/Ink Canvas/MainWindow.xaml.cs @@ -311,7 +311,10 @@ namespace Ink_Canvas // 应用无焦点模式设置 ApplyNoFocusMode(); // 应用窗口置顶设置 - ApplyAlwaysOnTop(); + Dispatcher.BeginInvoke(new Action(() => + { + ApplyAlwaysOnTop(); + }), DispatcherPriority.ApplicationIdle); // 添加窗口激活事件处理,确保置顶状态在窗口重新激活时得到保持 Activated += Window_Activated; @@ -1283,7 +1286,10 @@ namespace Ink_Canvas // 应用无焦点模式设置 ApplyNoFocusMode(); // 应用窗口置顶设置 - ApplyAlwaysOnTop(); + Dispatcher.BeginInvoke(new Action(() => + { + ApplyAlwaysOnTop(); + }), DispatcherPriority.ApplicationIdle); // 设置UIA置顶状态 App.IsUIAccessTopMostEnabled = Settings.Advanced.EnableUIAccessTopMost;