Phase 1: data models and local storage service
- Add Models: Category, ToolItem (IsValid runtime-only, not stored), AppConfig - Add Services: IDataService + JsonDataService (JSON load/save) - Path validation on Load(): File.Exists check, logs warning for missing paths - Startup: auto-calls dataService.Load() to load config
This commit is contained in:
@@ -20,6 +20,10 @@ public partial class App : Application
|
||||
ConfigureServices(services);
|
||||
Services = services.BuildServiceProvider();
|
||||
|
||||
// 启动时加载配置文件(含路径验证与容错)
|
||||
var dataService = Services.GetRequiredService<IDataService>();
|
||||
dataService.Load();
|
||||
|
||||
var mainWindow = Services.GetRequiredService<MainWindow>();
|
||||
mainWindow.Show();
|
||||
}
|
||||
@@ -32,6 +36,9 @@ public partial class App : Application
|
||||
// 日志服务
|
||||
services.AddSingleton<ILogService, LogService>();
|
||||
|
||||
// 数据持久化服务
|
||||
services.AddSingleton<IDataService, JsonDataService>();
|
||||
|
||||
// 主窗口
|
||||
services.AddSingleton<MainWindow>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user