This commit is contained in:
LanZhan
2025-09-22 18:06:26 +08:00
parent 4c9542f7f6
commit a5b4418e6c
12 changed files with 8 additions and 27 deletions

View File

@@ -38,7 +38,7 @@ public partial class App : Application
return service;
}
public static WindowEx? MainWindow { get; private set; }
public static WindowEx? MainWindow { get; set; }
public static UIElement? AppTitlebar { get; set; }
@@ -120,7 +120,6 @@ public partial class App : Application
protected async override void OnLaunched(LaunchActivatedEventArgs args)
{
base.OnLaunched(args);
MainWindow = new MainWindow();
await GetService<IActivationService>().ActivateAsync(args);
}

View File

@@ -8,8 +8,7 @@ public interface IMaterialSelectorService : IDisposable
bool IsFallBack { get; set; }
byte LuminosityOpacity { get; set; }
Color TintColor { get; set; }
void InitializeSettings();
Task InitializeMaterialAsync();
Task InitializeAsync();
Task<(byte, Color)> SetMaterial(
MaterialType material,
bool firstStart = false,

View File

@@ -180,7 +180,6 @@ public partial class MusicLibrary : ObservableRecipient
_ = Task.Run(LoadCovers);
_ = Task.Run(AddFolderWatcher);
_librarySemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
});
}
@@ -236,7 +235,6 @@ public partial class MusicLibrary : ObservableRecipient
{
_dispatcherQueue.TryEnqueue(() => IsProgressRingActive = false);
_librarySemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
});
}

View File

@@ -33,7 +33,6 @@ public partial class PlaylistLibrary : ObservableRecipient
{
playlist.GetCover();
}
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
public PlaylistInfo? NewPlaylist(string? name)

View File

@@ -74,7 +74,6 @@ public class CloudAlbumSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}
@@ -117,7 +116,6 @@ public class CloudAlbumSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}

View File

@@ -71,7 +71,6 @@ public class CloudArtistDetailSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
return info;
}
@@ -103,7 +102,6 @@ public class CloudArtistDetailSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}

View File

@@ -75,7 +75,6 @@ public class CloudArtistSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}
@@ -118,7 +117,6 @@ public class CloudArtistSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}

View File

@@ -75,7 +75,6 @@ public class CloudPlaylistSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}
@@ -118,7 +117,6 @@ public class CloudPlaylistSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}

View File

@@ -73,7 +73,6 @@ public class CloudSongSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}
@@ -116,7 +115,6 @@ public class CloudSongSearchHelper
finally
{
_searchSemaphore.Release();
GC.Collect(2, GCCollectionMode.Forced, true, true);
}
}

View File

@@ -18,17 +18,18 @@ public class ActivationService(IEnumerable<IActivationHandler> activationHandler
public async Task ActivateAsync(object activationArgs)
{
await Settings.InitializeAsync(); // 初始化设置
App.MainWindow = new MainWindow();
await InitializeAsync(); // 在激活之前执行的任务
await HandleActivationAsync(activationArgs); // 通过 ActivationHandlers 处理激活
App.MainWindow?.Activate(); // 打开 MainWindow
App.MainWindow.Activate(); // 打开 MainWindow
await StartupAsync(); // 在激活之后执行的任务
}
private async Task InitializeAsync()
{
await Settings.InitializeAsync().ConfigureAwait(false);
_themeSelectorService.Initialize();
_materialSelectorService.InitializeSettings();
await _materialSelectorService.InitializeAsync();
}
private async Task HandleActivationAsync(object activationArgs)
@@ -45,8 +46,6 @@ public class ActivationService(IEnumerable<IActivationHandler> activationHandler
private async Task StartupAsync()
{
_themeSelectorService.SetRequestedThemeAsync();
await _materialSelectorService.InitializeMaterialAsync();
await _dynamicBackgroundService.InitializeAsync();
}
}

View File

@@ -64,16 +64,12 @@ public partial class MaterialSelectorService : IMaterialSelectorService
}
}
public void InitializeSettings()
public async Task InitializeAsync()
{
Material = Settings.Material;
IsFallBack = Settings.IsFallBack;
LuminosityOpacity = Settings.LuminosityOpacity;
TintColor = Settings.TintColor;
}
public async Task InitializeMaterialAsync()
{
_mainWindow = App.MainWindow!;
_mainWindow.Activated += MainWindow_Activated;
((FrameworkElement)_mainWindow.Content).ActualThemeChanged += Window_ThemeChanged;

View File

@@ -27,6 +27,7 @@ public class ThemeSelectorService : IThemeSelectorService
public void Initialize()
{
Theme = Settings.Theme;
SetRequestedThemeAsync();
}
public void SetThemeAsync(ElementTheme theme)