From d72cd424833ddd44e5dd89a871767d99eb9d236c Mon Sep 17 00:00:00 2001 From: lincube Date: Sun, 8 Mar 2026 03:23:03 +0800 Subject: [PATCH] 0.4.11 --- .../Models/AppSettingsSnapshot.cs | 40 --- .../Models/DesktopLayoutSettingsSnapshot.cs | 43 +++ .../Models/LauncherSettingsSnapshot.cs | 22 ++ .../Services/DesktopLayoutSettingsService.cs | 248 ++++++++++++++++++ .../Services/LauncherSettingsService.cs | 236 +++++++++++++++++ .../Views/MainWindow.ComponentSystem.cs | 3 +- .../Views/MainWindow.DesktopPaging.cs | 4 +- .../Views/MainWindow.Settings.cs | 30 ++- LanMountainDesktop/Views/MainWindow.axaml.cs | 11 +- README.md | 1 + run.md | 2 +- 11 files changed, 585 insertions(+), 55 deletions(-) create mode 100644 LanMountainDesktop/Models/DesktopLayoutSettingsSnapshot.cs create mode 100644 LanMountainDesktop/Models/LauncherSettingsSnapshot.cs create mode 100644 LanMountainDesktop/Services/DesktopLayoutSettingsService.cs create mode 100644 LanMountainDesktop/Services/LauncherSettingsService.cs diff --git a/LanMountainDesktop/Models/AppSettingsSnapshot.cs b/LanMountainDesktop/Models/AppSettingsSnapshot.cs index fe686db..bd7e94f 100644 --- a/LanMountainDesktop/Models/AppSettingsSnapshot.cs +++ b/LanMountainDesktop/Models/AppSettingsSnapshot.cs @@ -70,16 +70,6 @@ public sealed class AppSettingsSnapshot public int StatusBarCustomSpacingPercent { get; set; } = 12; - public int DesktopPageCount { get; set; } = 1; - - public int CurrentDesktopSurfaceIndex { get; set; } = 0; - - public List DesktopComponentPlacements { get; set; } = []; - - public List HiddenLauncherFolderPaths { get; set; } = []; - - public List HiddenLauncherAppPaths { get; set; } = []; - public AppSettingsSnapshot Clone() { var clone = (AppSettingsSnapshot)MemberwiseClone(); @@ -91,36 +81,6 @@ public sealed class AppSettingsSnapshot ? new List(PinnedTaskbarActions) : []; - var placements = new List(DesktopComponentPlacements?.Count ?? 0); - if (DesktopComponentPlacements is not null) - { - foreach (var placement in DesktopComponentPlacements) - { - if (placement is null) - { - continue; - } - - placements.Add(new DesktopComponentPlacementSnapshot - { - PlacementId = placement.PlacementId, - PageIndex = placement.PageIndex, - ComponentId = placement.ComponentId, - Row = placement.Row, - Column = placement.Column, - WidthCells = placement.WidthCells, - HeightCells = placement.HeightCells - }); - } - } - clone.DesktopComponentPlacements = placements; - clone.HiddenLauncherFolderPaths = HiddenLauncherFolderPaths is { Count: > 0 } - ? new List(HiddenLauncherFolderPaths) - : []; - clone.HiddenLauncherAppPaths = HiddenLauncherAppPaths is { Count: > 0 } - ? new List(HiddenLauncherAppPaths) - : []; - return clone; } } diff --git a/LanMountainDesktop/Models/DesktopLayoutSettingsSnapshot.cs b/LanMountainDesktop/Models/DesktopLayoutSettingsSnapshot.cs new file mode 100644 index 0000000..617a593 --- /dev/null +++ b/LanMountainDesktop/Models/DesktopLayoutSettingsSnapshot.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; + +namespace LanMountainDesktop.Models; + +public sealed class DesktopLayoutSettingsSnapshot +{ + public int DesktopPageCount { get; set; } = 1; + + public int CurrentDesktopSurfaceIndex { get; set; } + + public List DesktopComponentPlacements { get; set; } = []; + + public DesktopLayoutSettingsSnapshot Clone() + { + var clone = (DesktopLayoutSettingsSnapshot)MemberwiseClone(); + var placements = new List(DesktopComponentPlacements?.Count ?? 0); + + if (DesktopComponentPlacements is not null) + { + foreach (var placement in DesktopComponentPlacements) + { + if (placement is null) + { + continue; + } + + placements.Add(new DesktopComponentPlacementSnapshot + { + PlacementId = placement.PlacementId, + PageIndex = placement.PageIndex, + ComponentId = placement.ComponentId, + Row = placement.Row, + Column = placement.Column, + WidthCells = placement.WidthCells, + HeightCells = placement.HeightCells + }); + } + } + + clone.DesktopComponentPlacements = placements; + return clone; + } +} diff --git a/LanMountainDesktop/Models/LauncherSettingsSnapshot.cs b/LanMountainDesktop/Models/LauncherSettingsSnapshot.cs new file mode 100644 index 0000000..7be9834 --- /dev/null +++ b/LanMountainDesktop/Models/LauncherSettingsSnapshot.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace LanMountainDesktop.Models; + +public sealed class LauncherSettingsSnapshot +{ + public List HiddenLauncherFolderPaths { get; set; } = []; + + public List HiddenLauncherAppPaths { get; set; } = []; + + public LauncherSettingsSnapshot Clone() + { + var clone = (LauncherSettingsSnapshot)MemberwiseClone(); + clone.HiddenLauncherFolderPaths = HiddenLauncherFolderPaths is { Count: > 0 } + ? new List(HiddenLauncherFolderPaths) + : []; + clone.HiddenLauncherAppPaths = HiddenLauncherAppPaths is { Count: > 0 } + ? new List(HiddenLauncherAppPaths) + : []; + return clone; + } +} diff --git a/LanMountainDesktop/Services/DesktopLayoutSettingsService.cs b/LanMountainDesktop/Services/DesktopLayoutSettingsService.cs new file mode 100644 index 0000000..141d086 --- /dev/null +++ b/LanMountainDesktop/Services/DesktopLayoutSettingsService.cs @@ -0,0 +1,248 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text.Json; +using LanMountainDesktop.Models; + +namespace LanMountainDesktop.Services; + +public sealed class DesktopLayoutSettingsService +{ + private static readonly JsonSerializerOptions SerializerOptions = new() + { + WriteIndented = true + }; + private static readonly object CacheGate = new(); + private static readonly TimeSpan CacheProbeInterval = TimeSpan.FromMilliseconds(400); + + private static string? _cachedPath; + private static DesktopLayoutSettingsSnapshot? _cachedSnapshot; + private static DateTime _cachedWriteTimeUtc = DateTime.MinValue; + private static DateTime _lastProbeUtc = DateTime.MinValue; + + private readonly string _settingsPath; + private readonly string _legacyAppSettingsPath; + + public DesktopLayoutSettingsService() + { + var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + var settingsDirectory = Path.Combine(appData, "LanMountainDesktop"); + _settingsPath = Path.Combine(settingsDirectory, "desktop-layout-settings.json"); + _legacyAppSettingsPath = Path.Combine(settingsDirectory, "settings.json"); + } + + public DesktopLayoutSettingsSnapshot Load() + { + try + { + lock (CacheGate) + { + var nowUtc = DateTime.UtcNow; + if (TryGetCachedWithoutProbe(nowUtc, out var cached)) + { + return cached; + } + + var hasFile = File.Exists(_settingsPath); + var writeTimeUtc = hasFile + ? File.GetLastWriteTimeUtc(_settingsPath) + : DateTime.MinValue; + + _lastProbeUtc = nowUtc; + if (TryGetCachedAfterProbe(writeTimeUtc, out cached)) + { + return cached; + } + + DesktopLayoutSettingsSnapshot loadedSnapshot; + var loadedFromLegacy = false; + if (hasFile) + { + loadedSnapshot = LoadSnapshotFromDisk(); + } + else if (TryLoadLegacySnapshot(out var migratedSnapshot)) + { + loadedSnapshot = migratedSnapshot; + loadedFromLegacy = true; + } + else + { + loadedSnapshot = new DesktopLayoutSettingsSnapshot(); + } + + var normalizedSnapshot = NormalizeSnapshot(loadedSnapshot); + if (loadedFromLegacy) + { + writeTimeUtc = PersistSnapshotToDisk(normalizedSnapshot); + } + + UpdateCache(normalizedSnapshot, writeTimeUtc, nowUtc); + return normalizedSnapshot.Clone(); + } + } + catch + { + return new DesktopLayoutSettingsSnapshot(); + } + } + + public void Save(DesktopLayoutSettingsSnapshot snapshot) + { + var snapshotToPersist = NormalizeSnapshot(snapshot); + + try + { + var writeTimeUtc = PersistSnapshotToDisk(snapshotToPersist); + + lock (CacheGate) + { + UpdateCache(snapshotToPersist, writeTimeUtc, DateTime.UtcNow); + } + } + catch + { + // Swallow persistence errors to keep UI interactions uninterrupted. + } + } + + private bool TryGetCachedWithoutProbe(DateTime nowUtc, out DesktopLayoutSettingsSnapshot snapshot) + { + if (string.Equals(_cachedPath, _settingsPath, StringComparison.Ordinal) && + _cachedSnapshot is not null && + nowUtc - _lastProbeUtc < CacheProbeInterval) + { + snapshot = _cachedSnapshot.Clone(); + return true; + } + + snapshot = null!; + return false; + } + + private bool TryGetCachedAfterProbe(DateTime writeTimeUtc, out DesktopLayoutSettingsSnapshot snapshot) + { + if (string.Equals(_cachedPath, _settingsPath, StringComparison.Ordinal) && + _cachedSnapshot is not null && + writeTimeUtc == _cachedWriteTimeUtc) + { + snapshot = _cachedSnapshot.Clone(); + return true; + } + + snapshot = null!; + return false; + } + + private DesktopLayoutSettingsSnapshot LoadSnapshotFromDisk() + { + try + { + var json = File.ReadAllText(_settingsPath); + var snapshot = JsonSerializer.Deserialize(json, SerializerOptions); + return NormalizeSnapshot(snapshot); + } + catch + { + return new DesktopLayoutSettingsSnapshot(); + } + } + + private bool TryLoadLegacySnapshot(out DesktopLayoutSettingsSnapshot snapshot) + { + snapshot = new DesktopLayoutSettingsSnapshot(); + + try + { + if (!File.Exists(_legacyAppSettingsPath)) + { + return false; + } + + var legacyJson = File.ReadAllText(_legacyAppSettingsPath); + var legacy = JsonSerializer.Deserialize(legacyJson, SerializerOptions); + if (legacy is null) + { + return false; + } + + snapshot = new DesktopLayoutSettingsSnapshot + { + DesktopPageCount = legacy.DesktopPageCount, + CurrentDesktopSurfaceIndex = legacy.CurrentDesktopSurfaceIndex, + DesktopComponentPlacements = legacy.DesktopComponentPlacements ?? [] + }; + + return true; + } + catch + { + return false; + } + } + + private DateTime PersistSnapshotToDisk(DesktopLayoutSettingsSnapshot snapshot) + { + var directory = Path.GetDirectoryName(_settingsPath); + if (!string.IsNullOrWhiteSpace(directory)) + { + Directory.CreateDirectory(directory); + } + + var json = JsonSerializer.Serialize(snapshot, SerializerOptions); + File.WriteAllText(_settingsPath, json); + + return File.Exists(_settingsPath) + ? File.GetLastWriteTimeUtc(_settingsPath) + : DateTime.UtcNow; + } + + private static DesktopLayoutSettingsSnapshot NormalizeSnapshot(DesktopLayoutSettingsSnapshot? snapshot) + { + var normalized = snapshot?.Clone() ?? new DesktopLayoutSettingsSnapshot(); + normalized.DesktopPageCount = Math.Max(1, normalized.DesktopPageCount); + normalized.CurrentDesktopSurfaceIndex = Math.Max(0, normalized.CurrentDesktopSurfaceIndex); + + var placements = new List(normalized.DesktopComponentPlacements?.Count ?? 0); + if (normalized.DesktopComponentPlacements is not null) + { + foreach (var placement in normalized.DesktopComponentPlacements) + { + if (placement is null) + { + continue; + } + + placements.Add(new DesktopComponentPlacementSnapshot + { + PlacementId = placement.PlacementId?.Trim() ?? string.Empty, + PageIndex = Math.Max(0, placement.PageIndex), + ComponentId = placement.ComponentId?.Trim() ?? string.Empty, + Row = Math.Max(0, placement.Row), + Column = Math.Max(0, placement.Column), + WidthCells = Math.Max(1, placement.WidthCells), + HeightCells = Math.Max(1, placement.HeightCells) + }); + } + } + + normalized.DesktopComponentPlacements = placements; + return normalized; + } + + private void UpdateCache(DesktopLayoutSettingsSnapshot snapshot, DateTime writeTimeUtc, DateTime probeTimeUtc) + { + _cachedPath = _settingsPath; + _cachedSnapshot = snapshot.Clone(); + _cachedWriteTimeUtc = writeTimeUtc; + _lastProbeUtc = probeTimeUtc; + } + + private sealed class LegacyDesktopLayoutSettingsSnapshot + { + public int DesktopPageCount { get; set; } = 1; + + public int CurrentDesktopSurfaceIndex { get; set; } + + public List? DesktopComponentPlacements { get; set; } + } +} diff --git a/LanMountainDesktop/Services/LauncherSettingsService.cs b/LanMountainDesktop/Services/LauncherSettingsService.cs new file mode 100644 index 0000000..a76e194 --- /dev/null +++ b/LanMountainDesktop/Services/LauncherSettingsService.cs @@ -0,0 +1,236 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.Json; +using LanMountainDesktop.Models; + +namespace LanMountainDesktop.Services; + +public sealed class LauncherSettingsService +{ + private static readonly JsonSerializerOptions SerializerOptions = new() + { + WriteIndented = true + }; + private static readonly object CacheGate = new(); + private static readonly TimeSpan CacheProbeInterval = TimeSpan.FromMilliseconds(400); + + private static string? _cachedPath; + private static LauncherSettingsSnapshot? _cachedSnapshot; + private static DateTime _cachedWriteTimeUtc = DateTime.MinValue; + private static DateTime _lastProbeUtc = DateTime.MinValue; + + private readonly string _settingsPath; + private readonly string _legacyAppSettingsPath; + + public LauncherSettingsService() + { + var appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + var settingsDirectory = Path.Combine(appData, "LanMountainDesktop"); + _settingsPath = Path.Combine(settingsDirectory, "launcher-settings.json"); + _legacyAppSettingsPath = Path.Combine(settingsDirectory, "settings.json"); + } + + public LauncherSettingsSnapshot Load() + { + try + { + lock (CacheGate) + { + var nowUtc = DateTime.UtcNow; + if (TryGetCachedWithoutProbe(nowUtc, out var cached)) + { + return cached; + } + + var hasFile = File.Exists(_settingsPath); + var writeTimeUtc = hasFile + ? File.GetLastWriteTimeUtc(_settingsPath) + : DateTime.MinValue; + + _lastProbeUtc = nowUtc; + if (TryGetCachedAfterProbe(writeTimeUtc, out cached)) + { + return cached; + } + + LauncherSettingsSnapshot loadedSnapshot; + var loadedFromLegacy = false; + if (hasFile) + { + loadedSnapshot = LoadSnapshotFromDisk(); + } + else if (TryLoadLegacySnapshot(out var migratedSnapshot)) + { + loadedSnapshot = migratedSnapshot; + loadedFromLegacy = true; + } + else + { + loadedSnapshot = new LauncherSettingsSnapshot(); + } + + var normalizedSnapshot = NormalizeSnapshot(loadedSnapshot); + if (loadedFromLegacy) + { + writeTimeUtc = PersistSnapshotToDisk(normalizedSnapshot); + } + + UpdateCache(normalizedSnapshot, writeTimeUtc, nowUtc); + return normalizedSnapshot.Clone(); + } + } + catch + { + return new LauncherSettingsSnapshot(); + } + } + + public void Save(LauncherSettingsSnapshot snapshot) + { + var snapshotToPersist = NormalizeSnapshot(snapshot); + + try + { + var writeTimeUtc = PersistSnapshotToDisk(snapshotToPersist); + + lock (CacheGate) + { + UpdateCache(snapshotToPersist, writeTimeUtc, DateTime.UtcNow); + } + } + catch + { + // Swallow persistence errors to keep UI interactions uninterrupted. + } + } + + private bool TryGetCachedWithoutProbe(DateTime nowUtc, out LauncherSettingsSnapshot snapshot) + { + if (string.Equals(_cachedPath, _settingsPath, StringComparison.Ordinal) && + _cachedSnapshot is not null && + nowUtc - _lastProbeUtc < CacheProbeInterval) + { + snapshot = _cachedSnapshot.Clone(); + return true; + } + + snapshot = null!; + return false; + } + + private bool TryGetCachedAfterProbe(DateTime writeTimeUtc, out LauncherSettingsSnapshot snapshot) + { + if (string.Equals(_cachedPath, _settingsPath, StringComparison.Ordinal) && + _cachedSnapshot is not null && + writeTimeUtc == _cachedWriteTimeUtc) + { + snapshot = _cachedSnapshot.Clone(); + return true; + } + + snapshot = null!; + return false; + } + + private LauncherSettingsSnapshot LoadSnapshotFromDisk() + { + try + { + var json = File.ReadAllText(_settingsPath); + var snapshot = JsonSerializer.Deserialize(json, SerializerOptions); + return NormalizeSnapshot(snapshot); + } + catch + { + return new LauncherSettingsSnapshot(); + } + } + + private bool TryLoadLegacySnapshot(out LauncherSettingsSnapshot snapshot) + { + snapshot = new LauncherSettingsSnapshot(); + + try + { + if (!File.Exists(_legacyAppSettingsPath)) + { + return false; + } + + var legacyJson = File.ReadAllText(_legacyAppSettingsPath); + var legacy = JsonSerializer.Deserialize(legacyJson, SerializerOptions); + if (legacy is null) + { + return false; + } + + snapshot = new LauncherSettingsSnapshot + { + HiddenLauncherFolderPaths = legacy.HiddenLauncherFolderPaths ?? [], + HiddenLauncherAppPaths = legacy.HiddenLauncherAppPaths ?? [] + }; + + return true; + } + catch + { + return false; + } + } + + private DateTime PersistSnapshotToDisk(LauncherSettingsSnapshot snapshot) + { + var directory = Path.GetDirectoryName(_settingsPath); + if (!string.IsNullOrWhiteSpace(directory)) + { + Directory.CreateDirectory(directory); + } + + var json = JsonSerializer.Serialize(snapshot, SerializerOptions); + File.WriteAllText(_settingsPath, json); + + return File.Exists(_settingsPath) + ? File.GetLastWriteTimeUtc(_settingsPath) + : DateTime.UtcNow; + } + + private static LauncherSettingsSnapshot NormalizeSnapshot(LauncherSettingsSnapshot? snapshot) + { + var normalized = snapshot?.Clone() ?? new LauncherSettingsSnapshot(); + normalized.HiddenLauncherFolderPaths = NormalizeKeys(normalized.HiddenLauncherFolderPaths); + normalized.HiddenLauncherAppPaths = NormalizeKeys(normalized.HiddenLauncherAppPaths); + return normalized; + } + + private static List NormalizeKeys(IReadOnlyList? values) + { + if (values is null || values.Count == 0) + { + return []; + } + + return values + .Where(value => !string.IsNullOrWhiteSpace(value)) + .Select(value => value.Trim()) + .Distinct(StringComparer.OrdinalIgnoreCase) + .OrderBy(value => value, StringComparer.OrdinalIgnoreCase) + .ToList(); + } + + private void UpdateCache(LauncherSettingsSnapshot snapshot, DateTime writeTimeUtc, DateTime probeTimeUtc) + { + _cachedPath = _settingsPath; + _cachedSnapshot = snapshot.Clone(); + _cachedWriteTimeUtc = writeTimeUtc; + _lastProbeUtc = probeTimeUtc; + } + + private sealed class LegacyLauncherSettingsSnapshot + { + public List? HiddenLauncherFolderPaths { get; set; } + + public List? HiddenLauncherAppPaths { get; set; } + } +} diff --git a/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs b/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs index 7fe3edc..0c85f51 100644 --- a/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs +++ b/LanMountainDesktop/Views/MainWindow.ComponentSystem.cs @@ -1431,7 +1431,7 @@ public partial class MainWindow ApplyTaskbarActionVisibility(GetCurrentTaskbarContext()); } - private void InitializeDesktopComponentPlacements(AppSettingsSnapshot snapshot) + private void InitializeDesktopComponentPlacements(DesktopLayoutSettingsSnapshot snapshot) { _desktopComponentPlacements.Clear(); @@ -3598,4 +3598,3 @@ public partial class MainWindow ApplyComponentLibraryComponentOffset(); } } - diff --git a/LanMountainDesktop/Views/MainWindow.DesktopPaging.cs b/LanMountainDesktop/Views/MainWindow.DesktopPaging.cs index 1f2dedc..a68e515 100644 --- a/LanMountainDesktop/Views/MainWindow.DesktopPaging.cs +++ b/LanMountainDesktop/Views/MainWindow.DesktopPaging.cs @@ -66,14 +66,14 @@ public partial class MainWindow private int TotalSurfaceCount => LauncherSurfaceIndex + 1; - private void InitializeDesktopSurfaceState(AppSettingsSnapshot snapshot) + private void InitializeDesktopSurfaceState(DesktopLayoutSettingsSnapshot snapshot) { var loadedPageCount = snapshot.DesktopPageCount <= 0 ? MinDesktopPageCount : snapshot.DesktopPageCount; _desktopPageCount = Math.Clamp(loadedPageCount, MinDesktopPageCount, MaxDesktopPageCount); _currentDesktopSurfaceIndex = Math.Clamp(snapshot.CurrentDesktopSurfaceIndex, 0, LauncherSurfaceIndex); } - private void InitializeLauncherVisibilitySettings(AppSettingsSnapshot snapshot) + private void InitializeLauncherVisibilitySettings(LauncherSettingsSnapshot snapshot) { _hiddenLauncherFolderPaths.Clear(); if (snapshot.HiddenLauncherFolderPaths is not null) diff --git a/LanMountainDesktop/Views/MainWindow.Settings.cs b/LanMountainDesktop/Views/MainWindow.Settings.cs index 187477a..7a0bbcd 100644 --- a/LanMountainDesktop/Views/MainWindow.Settings.cs +++ b/LanMountainDesktop/Views/MainWindow.Settings.cs @@ -864,7 +864,14 @@ public partial class MainWindow return; } - var snapshot = new AppSettingsSnapshot + _appSettingsService.Save(BuildAppSettingsSnapshot()); + _desktopLayoutSettingsService.Save(BuildDesktopLayoutSettingsSnapshot()); + _launcherSettingsService.Save(BuildLauncherSettingsSnapshot()); + } + + private AppSettingsSnapshot BuildAppSettingsSnapshot() + { + return new AppSettingsSnapshot { GridShortSideCells = _targetShortSideCells, GridSpacingPreset = _gridSpacingPreset, @@ -896,15 +903,27 @@ public partial class MainWindow TaskbarLayoutMode = _taskbarLayoutMode, ClockDisplayFormat = _clockDisplayFormat == ClockDisplayFormat.HourMinute ? "HourMinute" : "HourMinuteSecond", StatusBarSpacingMode = _statusBarSpacingMode, - StatusBarCustomSpacingPercent = _statusBarCustomSpacingPercent, + StatusBarCustomSpacingPercent = _statusBarCustomSpacingPercent + }; + } + + private DesktopLayoutSettingsSnapshot BuildDesktopLayoutSettingsSnapshot() + { + return new DesktopLayoutSettingsSnapshot + { DesktopPageCount = _desktopPageCount, CurrentDesktopSurfaceIndex = _currentDesktopSurfaceIndex, - DesktopComponentPlacements = _desktopComponentPlacements.ToList(), + DesktopComponentPlacements = _desktopComponentPlacements.ToList() + }; + } + + private LauncherSettingsSnapshot BuildLauncherSettingsSnapshot() + { + return new LauncherSettingsSnapshot + { HiddenLauncherFolderPaths = _hiddenLauncherFolderPaths.OrderBy(path => path, StringComparer.OrdinalIgnoreCase).ToList(), HiddenLauncherAppPaths = _hiddenLauncherAppPaths.OrderBy(path => path, StringComparer.OrdinalIgnoreCase).ToList() }; - - _appSettingsService.Save(snapshot); } private IDisposable? _persistSettingsDebounceTimer; @@ -2288,4 +2307,3 @@ public partial class MainWindow }; } } - diff --git a/LanMountainDesktop/Views/MainWindow.axaml.cs b/LanMountainDesktop/Views/MainWindow.axaml.cs index 4b1768b..fbb581b 100644 --- a/LanMountainDesktop/Views/MainWindow.axaml.cs +++ b/LanMountainDesktop/Views/MainWindow.axaml.cs @@ -88,6 +88,8 @@ public partial class MainWindow : Window } private readonly MonetColorService _monetColorService = new(); private readonly AppSettingsService _appSettingsService = new(); + private readonly DesktopLayoutSettingsService _desktopLayoutSettingsService = new(); + private readonly LauncherSettingsService _launcherSettingsService = new(); private readonly ComponentSettingsService _componentSettingsService = new(); private readonly LocalizationService _localizationService = new(); private readonly TimeZoneService _timeZoneService = new(); @@ -193,6 +195,8 @@ public partial class MainWindow : Window _suppressSettingsPersistence = true; var snapshot = _appSettingsService.Load(); + var desktopLayoutSnapshot = _desktopLayoutSettingsService.Load(); + var launcherSnapshot = _launcherSettingsService.Load(); if (!string.IsNullOrWhiteSpace(snapshot.TimeZoneId)) { @@ -247,9 +251,9 @@ public partial class MainWindow : Window _ = _componentSettingsService.Load(); InitializeAutoStartWithWindowsSetting(snapshot); InitializeUpdateSettings(snapshot); - InitializeDesktopSurfaceState(snapshot); - InitializeLauncherVisibilitySettings(snapshot); - InitializeDesktopComponentPlacements(snapshot); + InitializeDesktopSurfaceState(desktopLayoutSnapshot); + InitializeLauncherVisibilitySettings(launcherSnapshot); + InitializeDesktopComponentPlacements(desktopLayoutSnapshot); InitializeSettingsIcons(); TryRestoreWallpaper(snapshot.WallpaperPath); @@ -1341,4 +1345,3 @@ public partial class MainWindow : Window PersistSettings(); } } - diff --git a/README.md b/README.md index 9b2fad8..c40f51f 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ ## 当前状态 - 项目包含桌面端与推荐后端两个子项目,并在同一 solution 中维护。 - 配置默认写入本地:`%LOCALAPPDATA%\LanMountainDesktop\settings.json`。 +- 启动台与桌面布局现已拆分到独立文件:`%LOCALAPPDATA%\LanMountainDesktop\launcher-settings.json`、`%LOCALAPPDATA%\LanMountainDesktop\desktop-layout-settings.json`。 - 当前体验以 Windows 为主要目标平台。 ## 运行说明 diff --git a/run.md b/run.md index 9f13479..1aef366 100644 --- a/run.md +++ b/run.md @@ -1,4 +1,4 @@ -# LanMountainDesktop 运行指南 +# LanMountainDesktop 运行指南 本文档只负责“怎么跑起来”。项目介绍请看 [README.md](./README.md)。