mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 23:54:26 +08:00
changed.调整了开发者选项
This commit is contained in:
@@ -4,7 +4,10 @@
|
||||
|
||||
### 新增 (Added)
|
||||
|
||||
- 无
|
||||
- ✨ **开发者调试工具**: 新增开发者调试工具,优化插件开发体验
|
||||
- 提供便捷的调试功能,帮助开发者快速定位和解决问题
|
||||
- 支持插件运行时状态监控和日志查看
|
||||
- 提升插件开发效率和调试体验
|
||||
|
||||
### 变更 (Changed)
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ internal sealed class SettingsWindowService : ISettingsWindowService
|
||||
_localizationService = new();
|
||||
_settingsFacade.Settings.Changed += OnSettingsChanged;
|
||||
_appearanceThemeService.Changed += OnAppearanceThemeChanged;
|
||||
AppSettingsService.SettingsSaved += OnAppSettingsSaved;
|
||||
}
|
||||
|
||||
private string L(string key)
|
||||
@@ -279,6 +280,7 @@ internal sealed class SettingsWindowService : ISettingsWindowService
|
||||
var changedKeys = e.ChangedKeys?.ToArray();
|
||||
var refreshAll = changedKeys is null || changedKeys.Length == 0;
|
||||
var languageChanged = refreshAll || changedKeys.Contains(nameof(AppSettingsSnapshot.LanguageCode), StringComparer.OrdinalIgnoreCase);
|
||||
var devModeChanged = refreshAll || changedKeys.Contains(nameof(AppSettingsSnapshot.IsDevModeEnabled), StringComparer.OrdinalIgnoreCase);
|
||||
var liveAppearance = _appearanceThemeService.GetCurrent();
|
||||
var themeChanged =
|
||||
refreshAll ||
|
||||
@@ -291,14 +293,13 @@ internal sealed class SettingsWindowService : ISettingsWindowService
|
||||
changedKeys.Contains(nameof(AppSettingsSnapshot.WallpaperColor), StringComparer.OrdinalIgnoreCase))) ||
|
||||
changedKeys.Contains(nameof(AppSettingsSnapshot.UseSystemChrome), StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
if (languageChanged)
|
||||
if (languageChanged || devModeChanged)
|
||||
{
|
||||
var regionState = _settingsFacade.Region.Get();
|
||||
// 清除本地化缓存,强制重新加载语言文件
|
||||
_localizationService.ClearCache();
|
||||
_viewModel.RefreshLanguage(regionState.LanguageCode);
|
||||
_pageRegistry.Rebuild();
|
||||
_window.ReloadPages(_viewModel.CurrentPageId);
|
||||
_window.ReloadPages(devModeChanged ? "dev" : _viewModel.CurrentPageId);
|
||||
_window.RefreshShellText();
|
||||
}
|
||||
|
||||
@@ -311,6 +312,31 @@ internal sealed class SettingsWindowService : ISettingsWindowService
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void OnAppSettingsSaved(string instanceId)
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
{
|
||||
if (_window is null || _viewModel is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var snapshot = _settingsFacade.Settings.LoadSnapshot<AppSettingsSnapshot>(SettingsScope.App);
|
||||
var devPageVisible = _pageRegistry.GetPages().Any(p => p.PageId == "dev");
|
||||
|
||||
if (snapshot.IsDevModeEnabled && !devPageVisible)
|
||||
{
|
||||
_pageRegistry.Rebuild();
|
||||
_window.ReloadPages("dev");
|
||||
}
|
||||
else if (!snapshot.IsDevModeEnabled && devPageVisible)
|
||||
{
|
||||
_pageRegistry.Rebuild();
|
||||
_window.ReloadPages(null);
|
||||
}
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
private void ApplyTheme(SettingsWindow window)
|
||||
{
|
||||
var appearanceSnapshot = _appearanceThemeService.GetCurrent();
|
||||
|
||||
@@ -3,13 +3,14 @@ using System.Diagnostics;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.VisualTree;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using LanMountainDesktop.Models;
|
||||
using LanMountainDesktop.PluginSdk;
|
||||
using LanMountainDesktop.Services;
|
||||
using LanMountainDesktop.Services.Settings;
|
||||
using LanMountainDesktop.ViewModels;
|
||||
using LanMountainDesktop.Views;
|
||||
|
||||
namespace LanMountainDesktop.Views.SettingsPages;
|
||||
|
||||
@@ -95,7 +96,7 @@ public partial class AboutSettingsPage : SettingsPageBase
|
||||
if (_heroCardClickCount >= 3)
|
||||
{
|
||||
_heroCardClickCount = 0;
|
||||
_ = ShowMessageAsync("开发者模式", "开发者模式已启用,无需重复操作。");
|
||||
Debug.WriteLine("[AboutSettingsPage] Developer mode is already enabled.");
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -142,22 +143,9 @@ public partial class AboutSettingsPage : SettingsPageBase
|
||||
|
||||
AppLogger.Info("DevMode", "Developer mode enabled via About page activation.");
|
||||
|
||||
_ = ShowMessageAsync("开发者模式", "已启用开发者模式。重新打开设置窗口即可看到开发者选项。");
|
||||
|
||||
if (HostContext is not null)
|
||||
if (this.FindAncestorOfType<SettingsWindow>() is { } settingsWindow)
|
||||
{
|
||||
HostContext.RequestRestart("开发者模式已更改");
|
||||
settingsWindow.RebuildAndNavigateToDevPage();
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task ShowMessageAsync(string title, string message)
|
||||
{
|
||||
var dialog = new ContentDialog
|
||||
{
|
||||
Title = title,
|
||||
Content = message,
|
||||
CloseButtonText = "确定"
|
||||
};
|
||||
await dialog.ShowAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,12 @@ public partial class SettingsWindow : Window, ISettingsPageHostContext
|
||||
NavigateTo(pageId ?? ViewModel.Pages.FirstOrDefault()?.PageId);
|
||||
}
|
||||
|
||||
public void RebuildAndNavigateToDevPage()
|
||||
{
|
||||
_pageRegistry.Rebuild();
|
||||
ReloadPages("dev");
|
||||
}
|
||||
|
||||
public void OpenDrawer(Control content, string? title = null)
|
||||
{
|
||||
if (DrawerContentHost is null)
|
||||
|
||||
Reference in New Issue
Block a user