diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..b4f16de
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,11 @@
+
+
+
+ net8.0
+ enable
+ 5.0.0.0
+ Zony(real-zony)
+ https://github.com/real-zony/ZonyLrcToolsX
+
+
+
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Cli/ZonyLrcTools.Cli.csproj b/src/ZonyLrcTools.Cli/ZonyLrcTools.Cli.csproj
index 90991dd..5076ab1 100644
--- a/src/ZonyLrcTools.Cli/ZonyLrcTools.Cli.csproj
+++ b/src/ZonyLrcTools.Cli/ZonyLrcTools.Cli.csproj
@@ -3,10 +3,6 @@
net8.0
Exe
- 0.0.0.1
- 0.0.0.1
- 0.0.0.1
- 0.0.0.1
diff --git a/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj b/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
index 650411f..b2a4c7a 100644
--- a/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
+++ b/src/ZonyLrcTools.Common/ZonyLrcTools.Common.csproj
@@ -4,7 +4,6 @@
net8.0
enable
enable
- 4.0.0.58
diff --git a/src/ZonyLrcTools.Desktop/App.axaml b/src/ZonyLrcTools.Desktop/App.axaml
index fb9057b..0d50b1f 100644
--- a/src/ZonyLrcTools.Desktop/App.axaml
+++ b/src/ZonyLrcTools.Desktop/App.axaml
@@ -14,7 +14,20 @@
+
+
+
+
+
+
+
Microsoft YaHei, Simsun, Arial
+
+
+
+
+
diff --git a/src/ZonyLrcTools.Desktop/App.axaml.cs b/src/ZonyLrcTools.Desktop/App.axaml.cs
index dba6084..4d81481 100644
--- a/src/ZonyLrcTools.Desktop/App.axaml.cs
+++ b/src/ZonyLrcTools.Desktop/App.axaml.cs
@@ -4,30 +4,29 @@ using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using Microsoft.Extensions.DependencyInjection;
using ZonyLrcTools.Common.Infrastructure.DependencyInject;
+using ZonyLrcTools.Common.Infrastructure.Network;
using ZonyLrcTools.Desktop.ViewModels;
using ZonyLrcTools.Desktop.Views;
namespace ZonyLrcTools.Desktop;
-public partial class App : Application
+public class App : Application
{
public new static App Current => (App)Application.Current!;
- public IServiceProvider Services { get; }
+ public IServiceProvider Services { get; } = ConfigureServices();
- public App()
- {
- Services = ConfigureServices();
- }
-
private static IServiceProvider ConfigureServices()
{
var services = new ServiceCollection();
+ services.BeginAutoDependencyInject();
+ services.BeginAutoDependencyInject();
services.ConfigureConfiguration();
-
+ services.ConfigureToolService();
+
return services.BuildServiceProvider();
}
-
+
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
diff --git a/src/ZonyLrcTools.Desktop/Helpers/UrlHelper.cs b/src/ZonyLrcTools.Desktop/Helpers/UrlHelper.cs
new file mode 100644
index 0000000..ffd88f3
--- /dev/null
+++ b/src/ZonyLrcTools.Desktop/Helpers/UrlHelper.cs
@@ -0,0 +1,33 @@
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+namespace ZonyLrcTools.Desktop.Helpers;
+
+public static class UrlHelper
+{
+ public static void OpenLink(string url)
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ using var process = Process.Start(new ProcessStartInfo
+ {
+ FileName = "/bin/sh",
+ Arguments = $"-c \"xdg-open {url.Replace("\"", "\\\"")}\"",
+ RedirectStandardOutput = true,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden
+ });
+ }
+ else
+ {
+ using var process = Process.Start(new ProcessStartInfo
+ {
+ FileName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? url : "open",
+ Arguments = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? url : "",
+ CreateNoWindow = true,
+ UseShellExecute = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
+ });
+ }
+ }
+}
diff --git a/src/ZonyLrcTools.Desktop/Infrastructure/Logging/SerilogWarpLogger.cs b/src/ZonyLrcTools.Desktop/Infrastructure/Logging/SerilogWarpLogger.cs
new file mode 100644
index 0000000..14ad8dd
--- /dev/null
+++ b/src/ZonyLrcTools.Desktop/Infrastructure/Logging/SerilogWarpLogger.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using ZonyLrcTools.Common.Infrastructure.DependencyInject;
+using ZonyLrcTools.Common.Infrastructure.Logging;
+
+namespace ZonyLrcTools.Desktop.Infrastructure.Logging;
+
+public class SerilogWarpLogger(ILogger logger) : IWarpLogger, ITransientDependency
+{
+ public Task DebugAsync(string message, Exception? exception = null)
+ {
+ logger.LogDebug(message, exception);
+
+ return Task.CompletedTask;
+ }
+
+ public Task InfoAsync(string message, Exception? exception = null)
+ {
+ logger.LogInformation(message, exception);
+ return Task.CompletedTask;
+ }
+
+ public Task WarnAsync(string message, Exception? exception = null)
+ {
+ logger.LogWarning(message, exception);
+ return Task.CompletedTask;
+ }
+
+ public Task ErrorAsync(string message, Exception? exception = null)
+ {
+ logger.LogError(message, exception);
+ return Task.CompletedTask;
+ }
+}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml b/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml
index d320b3c..527c6c2 100644
--- a/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml
+++ b/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml
@@ -5,20 +5,36 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ZonyLrcTools.Desktop.Pages.SettingsPage"
xmlns:ui="using:FluentAvalonia.UI.Controls"
- xmlns:viewModels="clr-namespace:ZonyLrcTools.Desktop.ViewModels"
xmlns:settings="clr-namespace:ZonyLrcTools.Desktop.ViewModels.Settings"
x:DataType="settings:LyricsSettingsViewModel">
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -28,19 +44,19 @@
-
+
-
+
-
+
@@ -50,15 +66,15 @@
-
+
-
-
+
+
@@ -67,13 +83,13 @@
-
+
-
+
@@ -84,26 +100,25 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
@@ -112,13 +127,13 @@
-
+
-
+
@@ -138,6 +153,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml.cs b/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml.cs
index 47f49ad..edc3e58 100644
--- a/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml.cs
+++ b/src/ZonyLrcTools.Desktop/Pages/SettingsPage.axaml.cs
@@ -1,8 +1,9 @@
using Avalonia.Controls;
+using Avalonia.Interactivity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using ZonyLrcTools.Common.Configuration;
-using ZonyLrcTools.Desktop.ViewModels;
+using ZonyLrcTools.Desktop.Helpers;
using ZonyLrcTools.Desktop.ViewModels.Settings;
namespace ZonyLrcTools.Desktop.Pages;
@@ -14,4 +15,6 @@ public partial class SettingsPage : UserControl
InitializeComponent();
DataContext = new LyricsSettingsViewModel(App.Current.Services.GetRequiredService>().Value);
}
+
+ private void OnGitHubClick(object? sender, RoutedEventArgs? eventArgs) => UrlHelper.OpenLink("https://github.com/real-zony/ZonyLrcToolsX");
}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Desktop/ViewModels/HomeViewModel.cs b/src/ZonyLrcTools.Desktop/ViewModels/HomeViewModel.cs
index a552f65..f04b5e1 100644
--- a/src/ZonyLrcTools.Desktop/ViewModels/HomeViewModel.cs
+++ b/src/ZonyLrcTools.Desktop/ViewModels/HomeViewModel.cs
@@ -1,11 +1,12 @@
using System.Collections.ObjectModel;
using ReactiveUI;
+using ZonyLrcTools.Common;
namespace ZonyLrcTools.Desktop.ViewModels;
public class HomeViewModel : ViewModelBase
{
- public ObservableCollection Songs { get; } = [];
+ public ObservableCollection Songs { get; } = [];
private double _downloadProgress;
@@ -16,10 +17,20 @@ public class HomeViewModel : ViewModelBase
}
}
-public class SongInfo
+public class SongInfoViewModel(MusicInfo info)
{
- public string SongName { get; set; }
- public string ArtistName { get; set; }
- public string FilePath { get; set; }
- public string DownloadStatus { get; set; }
+ private MusicInfo Info { get; } = info;
+
+ public string SongName => Info.Name;
+ public string ArtistName => Info.Artist;
+ public string FilePath => Info.FilePath;
+
+ public DownloadStatus DownloadStatus { get; set; } = DownloadStatus.NotStarted;
+}
+
+public enum DownloadStatus
+{
+ NotStarted = 1,
+ Completed,
+ Failed
}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Desktop/ViewModels/Settings/LyricsSettingsViewModel.cs b/src/ZonyLrcTools.Desktop/ViewModels/Settings/LyricsSettingsViewModel.cs
index 4540e31..a8c967e 100644
--- a/src/ZonyLrcTools.Desktop/ViewModels/Settings/LyricsSettingsViewModel.cs
+++ b/src/ZonyLrcTools.Desktop/ViewModels/Settings/LyricsSettingsViewModel.cs
@@ -20,6 +20,8 @@ public class LyricsSettingsViewModel : ViewModelBase
BrowseBlockWordFileCommand = ReactiveCommand.Create(BrowseBlockWordFile);
}
+ public static string Version => typeof(Program).Assembly.GetName().Version!.ToString();
+
public TagInfoViewModel Tag { get; }
public ReactiveCommand BrowseBlockWordFileCommand { get; }
diff --git a/src/ZonyLrcTools.Desktop/Views/MainView.axaml.cs b/src/ZonyLrcTools.Desktop/Views/MainView.axaml.cs
index 3769331..7a747e0 100644
--- a/src/ZonyLrcTools.Desktop/Views/MainView.axaml.cs
+++ b/src/ZonyLrcTools.Desktop/Views/MainView.axaml.cs
@@ -1,9 +1,14 @@
+using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Platform.Storage;
+using DynamicData;
using FluentAvalonia.UI.Controls;
+using Microsoft.Extensions.DependencyInjection;
+using ZonyLrcTools.Common;
using ZonyLrcTools.Desktop.Pages;
+using ZonyLrcTools.Desktop.ViewModels;
namespace ZonyLrcTools.Desktop.Views;
@@ -41,14 +46,20 @@ public partial class MainView : UserControl
private async void OnOpenFolderButtonClick(object? sender, RoutedEventArgs e)
{
var storage = _window?.StorageProvider;
- if (storage?.CanOpen == true)
+ var musicInfoLoader = App.Current.Services.GetRequiredService();
+
+ if (storage?.CanOpen == true && DataContext is HomeViewModel vm)
{
var options = new FolderPickerOpenOptions
{
SuggestedStartLocation = await storage.TryGetWellKnownFolderAsync(WellKnownFolder.Music)
};
var folders = await storage.OpenFolderPickerAsync(options);
- var folderPath = folders[0].Path;
+ var folderPath = folders[0].Path.LocalPath;
+ var musicInfos = await musicInfoLoader.LoadAsync(folderPath);
+
+ vm.Songs.Clear();
+ vm.Songs.AddRange(musicInfos.Select(x => new SongInfoViewModel(x!)));
}
}
diff --git a/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs b/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs
index fa81cf5..cdbe3d4 100644
--- a/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs
+++ b/src/ZonyLrcTools.Desktop/Views/MainWindow.axaml.cs
@@ -1,4 +1,5 @@
using Avalonia.Controls;
+using ZonyLrcTools.Desktop.ViewModels;
namespace ZonyLrcTools.Desktop.Views;
@@ -6,6 +7,7 @@ public partial class MainWindow : Window
{
public MainWindow()
{
+ DataContext = new HomeViewModel();
InitializeComponent();
}
}
\ No newline at end of file
diff --git a/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj b/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj
index fb2cc14..02c4d26 100644
--- a/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj
+++ b/src/ZonyLrcTools.Desktop/ZonyLrcTools.Desktop.csproj
@@ -22,6 +22,7 @@
+