重构项目结构,引入 Avalonia-Common、Avalonia-EFCore、Avalonia-Services,实现 API 与桌面端统一端点注册、过滤器、鉴权和标准响应格式。支持多数据库自动迁移与配置,集成 Serilog 日志系统。移除旧路由与控制器,提升接口一致性与可维护性。
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using Avalonia_Services.Core;
|
|
using Avalonia_Services.Endpoints;
|
|
using Avalonia_Services.Extensions;
|
|
using Avalonia_Services.Services;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Avalonia_PC.Views
|
|
{
|
|
public partial class MainWindow
|
|
{
|
|
/// <summary>
|
|
/// 统一端点适配器(替代原来的 _routes 字典)。
|
|
/// 所有端点在 Avalonia-Services/AppEndpoints.cs 中统一定义。
|
|
/// </summary>
|
|
private DesktopEndpointAdapter _endpointAdapter = null!;
|
|
|
|
/// <summary>
|
|
/// 服务容器,通过构造函数注入。
|
|
/// </summary>
|
|
private IServiceProvider _services = null!;
|
|
|
|
private void RegisterRoutes()
|
|
{
|
|
// 从 DI 获取已构建的端点集合
|
|
var endpointCollection = _services.GetRequiredService<ServiceEndpointCollection>();
|
|
_endpointAdapter = endpointCollection.CreateAdapter(_services);
|
|
}
|
|
}
|
|
}
|