diff --git a/src/BlueCatKoKo.Ui/App.xaml.cs b/src/BlueCatKoKo.Ui/App.xaml.cs index d5742d6..62163d7 100644 --- a/src/BlueCatKoKo.Ui/App.xaml.cs +++ b/src/BlueCatKoKo.Ui/App.xaml.cs @@ -1,22 +1,19 @@ -using System.Text; +using System.Reflection; +using System.Text; using System.Windows; using System.Windows.Threading; - using BlueCatKoKo.Ui.Models; using BlueCatKoKo.Ui.Services; using BlueCatKoKo.Ui.ViewModels; using BlueCatKoKo.Ui.ViewModels.Pages; using BlueCatKoKo.Ui.Views; using BlueCatKoKo.Ui.Views.Pages; - using CommunityToolkit.Mvvm.Messaging; - +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; - using Serilog; - using Wpf.Ui; namespace BlueCatKoKo.Ui @@ -37,7 +34,7 @@ public partial class App : Application Log.Logger = new LoggerConfiguration() .WriteTo.Console() .WriteTo.File( - "log.txt", rollingInterval: RollingInterval.Day,encoding:Encoding.UTF8 + "log.txt", rollingInterval: RollingInterval.Day, encoding: Encoding.UTF8 ) .CreateLogger(); logging.Services.AddSingleton(Log.Logger); @@ -46,7 +43,27 @@ public partial class App : Application { container.AddHostedService(); // configuration - container.Configure(context.Configuration.GetSection(nameof(AppConfig))); + // 绑定 AppConfig 配置段 + var appConfig = new AppConfig(); + context.Configuration.GetSection(nameof(AppConfig)).Bind(appConfig); + + // 获取程序集版本 + var version = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); + + appConfig.Version = version; // 将版本赋值给 AppConfig + + // container.Configure(context.Configuration.GetSection(nameof(AppConfig))); + + container.AddSingleton(appConfig); + container.Configure(config => + { + config.Name = appConfig.Name; + config.TrayTitle = appConfig.TrayTitle; + config.Description = appConfig.Description; + config.DownloadPath = appConfig.DownloadPath; + config.RepositoryUrl = appConfig.RepositoryUrl; + config.Version = appConfig.Version; + }); container.AddSingleton(); // Service containing diff --git a/src/BlueCatKoKo.Ui/BlueCatKoKo.Ui.csproj b/src/BlueCatKoKo.Ui/BlueCatKoKo.Ui.csproj index dbc4c78..72e576f 100644 --- a/src/BlueCatKoKo.Ui/BlueCatKoKo.Ui.csproj +++ b/src/BlueCatKoKo.Ui/BlueCatKoKo.Ui.csproj @@ -8,7 +8,7 @@ applicationIcon.ico AnyCPU;x64 BlueCatKoKo - 1.2.5 + 1.2.6.0 true false diff --git a/src/BlueCatKoKo.Ui/appsettings.json b/src/BlueCatKoKo.Ui/appsettings.json index f73bceb..8ad490a 100644 --- a/src/BlueCatKoKo.Ui/appsettings.json +++ b/src/BlueCatKoKo.Ui/appsettings.json @@ -2,7 +2,6 @@ "AppConfig": { "Name": "BlueCatKoKo", "TrayTitle": "BlueCatKoKo-DY-Downloader", - "Version": "v1.2.5", "Description": "BlueCatKoKo is a Douyin Downloader", "DownloadPath": "./", "RepositoryUrl": "https://github.com/K12f/BlueCatKoKo",