chore: 完成v1.2版本迭代与代码清理

本次提交完成了多项清理与规范工作:
1. 移除默认管理员硬编码配置与云同步相关代码
2. 简化前端与MAUI端的配置,关闭静态资源托管以外的冗余功能
3. 清理.gitignore与协调目录,移除临时文件与冗余规则
4. 统一项目命名规范,修正包名与版本号
5. 重构后端数据模型,移除ABP审计字段与云同步相关逻辑
6. 简化WebView配置与系统栏样式,移除不必要的平台检测代码
7. 更新文档与规则文件,完善项目规范与版本记录
This commit is contained in:
ShaoHua
2026-06-15 22:06:58 +08:00
parent 46db04e43e
commit cf96c56bed
70 changed files with 2514 additions and 2092 deletions
+7 -71
View File
@@ -1,20 +1,15 @@
using System.Text.Json;
using Microsoft.EntityFrameworkCore;
using Hua.Todo.Application;
using Hua.Todo.Application.CloudSync;
using Hua.Todo.Application.DynamicApi;
using Hua.Todo.Application.DynamicApi.Swagger;
using Hua.Todo.Application.Interfaces;
using Hua.Todo.Application.CloudSync.Services;
using Hua.Todo.Application.Models;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(options =>
{
options.DocumentFilter<DynamicApiSwaggerDocumentFilter>();
});
builder.Services.AddCloudSyncServer();
builder.Services.AddSwaggerGen();
builder.Services.AddAuthorization();
builder.Services.AddApplicationServices("Data Source=Hua.Todo.db");
@@ -24,69 +19,17 @@ builder.Services.AddCors(options =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.SetPreflightMaxAge(TimeSpan.FromMinutes(30));
.AllowAnyHeader();
});
});
var app = builder.Build();
// Apply database migrations and seed default admin
// Apply database migrations
using (var scope = app.Services.CreateScope())
{
var services = scope.ServiceProvider;
var dbContext = services.GetRequiredService<Hua.Todo.Application.Data.TodoDbContext>();
var dbContext = scope.ServiceProvider.GetRequiredService<Hua.Todo.Application.Data.TodoDbContext>();
dbContext.Database.Migrate();
var config = services.GetRequiredService<IConfiguration>();
var authService = services.GetRequiredService<CloudAuthService>();
var adminConfig = config.GetSection("DefaultAdmin");
var adminUserName = adminConfig["UserName"];
var adminPassword = adminConfig["Password"];
if (!string.IsNullOrWhiteSpace(adminUserName))
{
var result = await authService.BootstrapAdminAsync(adminUserName, adminPassword, "system", "seeding", CancellationToken.None);
if (result != null)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("========================================");
Console.WriteLine("首次启动:已创建默认管理员账号");
Console.WriteLine($"用户名: {result.UserName}");
if (!string.IsNullOrEmpty(adminPassword))
{
Console.WriteLine($"密码: {adminPassword}(已在配置中设置)");
}
else
{
Console.WriteLine($"临时密码: {result.GeneratedPassword}");
Console.WriteLine("请立即登录并修改密码!");
}
Console.WriteLine("========================================");
Console.ResetColor();
}
}
else
{
var hasAnyCloudUser = await dbContext.Users.AsNoTracking().AnyAsync(u => u.Role != "local");
if (!hasAnyCloudUser)
{
var defaultUserName = "admin";
var result = await authService.BootstrapAdminAsync(defaultUserName, null, "system", "auto-seeding", CancellationToken.None);
if (result != null)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("========================================");
Console.WriteLine("首次启动:已自动创建管理员账号");
Console.WriteLine($"用户名: {result.UserName}");
Console.WriteLine($"临时密码: {result.GeneratedPassword}");
Console.WriteLine("请立即登录并修改密码!");
Console.WriteLine("========================================");
Console.ResetColor();
}
}
}
}
if (app.Environment.IsDevelopment())
@@ -95,16 +38,9 @@ if (app.Environment.IsDevelopment())
app.UseSwaggerUI();
}
app.UseCors("AllowAll");
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseCors("AllowAll");
app.UseAuthorization();
// 简单的管理后台入口跳转
app.MapGet("/admin", () => Results.Redirect("/admin/index.html"));
app.MapCloudSyncEndpoints();
app.UseDynamicApi();
app.Run();