feat: 实现v1.2.0云同步与实体重构核心功能
1. 重构用户与任务实体:UserEntity实现IUser<Guid>,TaskEntity继承ABP风格FullAuditedEntityWithUser,主键从int改为Guid 2. 新增云同步代理系统:嵌入式WebServer支持CloudSyncProxy转发云同步请求,新增配置API与持久化 3. 完善前端适配:新增Guid工具函数,更新任务类型定义与API交互逻辑,调整云同步设置弹窗适配本地代理 4. 文档与配置优化:更新文档结构,新增部署文档、版本记录,统一各项目配置项 5. 补充测试与迁移:新增单元测试,更新EF Core数据库迁移快照
This commit is contained in:
@@ -7,6 +7,7 @@ using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Text.Json;
|
||||
using Hua.Todo.Application;
|
||||
using Hua.Todo.Application.CloudSync;
|
||||
using Hua.Todo.Application.DynamicApi;
|
||||
using Hua.Todo.Application.DynamicApi.Swagger;
|
||||
using Hua.Todo.Maui.Models;
|
||||
@@ -76,6 +77,13 @@ public class EmbeddedWebServerService : IEmbeddedWebServerService
|
||||
// 注册应用逻辑服务
|
||||
builder.Services.AddApplicationServices(_appSettings.WebServer.ConnectionString);
|
||||
|
||||
// 注册云同步反向代理(URL 管理 + 转发用 HttpClient)
|
||||
builder.Services.AddCloudSyncProxy();
|
||||
|
||||
// 注册 URL 持久化
|
||||
builder.Services.AddSingleton(new CloudSyncProxySettingsPersistence(
|
||||
Path.Combine(AppContext.BaseDirectory, "appsettings.json")));
|
||||
|
||||
// 配置跨域策略
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
@@ -89,6 +97,13 @@ public class EmbeddedWebServerService : IEmbeddedWebServerService
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// 从 appsettings 初始化 CloudSyncUrl
|
||||
var proxySettings = app.Services.GetRequiredService<CloudSyncProxySettings>();
|
||||
if (!string.IsNullOrEmpty(_appSettings.WebServer.CloudSyncUrl))
|
||||
{
|
||||
proxySettings.SetUrl(_appSettings.WebServer.CloudSyncUrl);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
@@ -101,9 +116,11 @@ public class EmbeddedWebServerService : IEmbeddedWebServerService
|
||||
}
|
||||
|
||||
app.UseCors("AllowAll");
|
||||
app.UseCloudSyncProxy(); // 云同步反向代理(在授权之前,由远程 Host 做鉴权)
|
||||
app.UseAuthorization();
|
||||
app.UseDynamicApi();
|
||||
app.MapControllers();
|
||||
app.MapCloudSyncProxySettings(); // GET/POST /api/cloud-sync/settings
|
||||
|
||||
_webApp = app;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user