119 lines
3.6 KiB
C#
119 lines
3.6 KiB
C#
using VideoAnalysisCore.Common;
|
||
using Learn.VideoAnalysis.Components;
|
||
using Microsoft.OpenApi.Models;
|
||
using AntDesign.ProLayout;
|
||
using VideoAnalysisCore.AICore.ChatGPT;
|
||
using VideoAnalysisCore.AICore.ChatGPT.KIMI;
|
||
using VideoAnalysisCore.AICore.SherpaOnnx;
|
||
using Mapster;
|
||
|
||
|
||
|
||
namespace Learn.VideoAnalysis
|
||
{
|
||
public class Program
|
||
{
|
||
public static void Main(string[] args)
|
||
{
|
||
|
||
var builder = WebApplication.CreateBuilder(args);
|
||
|
||
// Add services to the container.
|
||
builder.Services.AddRazorComponents()
|
||
.AddInteractiveServerComponents();
|
||
//.AddInteractiveWebAssemblyComponents();
|
||
|
||
builder.Services.AddHttpContextAccessor();
|
||
|
||
|
||
builder.Services.AddControllers();
|
||
|
||
builder.Services.AddEndpointsApiExplorer();
|
||
builder.Services.AddSwaggerGen(c =>
|
||
{
|
||
c.SwaggerDoc("v1", new OpenApiInfo
|
||
{
|
||
Title = "Learn.VideoAnalysis",
|
||
Version = "v1",
|
||
Description = "教学视频分析平台v1"
|
||
});
|
||
var file = Path.Combine(AppContext.BaseDirectory, "Learn.VideoAnalysis.xml"); // xml文档绝对路径
|
||
c.IncludeXmlComments(file, true); // true : 显示控制器层注释
|
||
c.OrderActionsBy(o => o.RelativePath); // 对action的名称进行排序,如果有多个,就可以看见效果了。
|
||
});
|
||
|
||
//绑定 appsetting 配置
|
||
builder.Configuration.GetSection("AppConfig").Bind(AppCommon.Config);
|
||
|
||
//初始化 插件
|
||
builder.Services.InitSqlSugar();
|
||
RedisExpand.Init();
|
||
Speaker.Init();
|
||
//SenseVoice.Init();
|
||
builder.Services.AddControllersWithViews(options =>
|
||
{
|
||
options.Filters.Add(typeof(ExceptionFilter));
|
||
});
|
||
|
||
|
||
builder.Services.AddScoped(sp =>
|
||
{
|
||
var httpContext = sp.GetRequiredService<IHttpContextAccessor>().HttpContext;
|
||
if (httpContext != null)
|
||
{
|
||
return new HttpClient
|
||
{
|
||
BaseAddress = new Uri(httpContext.Request.Scheme + "://" + httpContext.Request.Host)
|
||
};
|
||
}
|
||
return new HttpClient();
|
||
});
|
||
|
||
//VideoAnalysisRazor.Program.AddClientServices(builder.Services);
|
||
|
||
builder.Services.AddAntDesign();
|
||
builder.Services.AddMapster();
|
||
|
||
|
||
builder.Services.Configure<ProSettings>(builder.Configuration.GetSection("ProSettings"));
|
||
|
||
builder.Services.AddHttpClient();
|
||
builder.Services.AddSingleton<MoonshotClient>();
|
||
builder.Services.AddSingleton<IBserGPT, KIMI_GPT>();
|
||
|
||
|
||
var app = builder.Build();
|
||
|
||
AppCommon.Services = app.Services;
|
||
|
||
// Configure the HTTP request pipeline.
|
||
if (app.Environment.IsDevelopment())
|
||
{
|
||
app.UseSwagger();
|
||
app.UseSwaggerUI();
|
||
app.UseExceptionHandler("/Error");
|
||
}
|
||
//else
|
||
//{
|
||
// app.UseExceptionHandler("/Login");
|
||
//}
|
||
|
||
|
||
app.UseStaticFiles();
|
||
app.UseAntiforgery();
|
||
|
||
app.MapRazorComponents<App>()
|
||
.AddInteractiveServerRenderMode();
|
||
//.AddInteractiveWebAssemblyRenderMode()
|
||
//.AddAdditionalAssemblies(typeof(VideoAnalysisRazor._Imports).Assembly);
|
||
|
||
app.MapControllers();
|
||
|
||
SqlSugarExpand.InitDB();
|
||
|
||
app.Run();
|
||
|
||
}
|
||
}
|
||
}
|