2024-05-10 19:52:37 +00:00
|
|
|
using System.Reflection;
|
|
|
|
|
2024-05-04 08:47:42 +00:00
|
|
|
using AIStudio;
|
2024-04-05 20:21:44 +00:00
|
|
|
using AIStudio.Components;
|
2024-04-19 19:19:13 +00:00
|
|
|
using AIStudio.Settings;
|
2024-05-04 08:49:09 +00:00
|
|
|
using AIStudio.Tools;
|
2024-04-20 15:03:57 +00:00
|
|
|
|
2024-05-10 19:52:37 +00:00
|
|
|
using Microsoft.Extensions.FileProviders;
|
|
|
|
|
2024-04-05 14:16:33 +00:00
|
|
|
using MudBlazor;
|
|
|
|
using MudBlazor.Services;
|
2024-03-28 21:26:48 +00:00
|
|
|
|
2024-05-11 11:30:17 +00:00
|
|
|
var builder = WebApplication.CreateBuilder();
|
2024-05-04 08:41:14 +00:00
|
|
|
builder.Services.AddMudServices(config =>
|
|
|
|
{
|
|
|
|
config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft;
|
|
|
|
config.SnackbarConfiguration.PreventDuplicates = false;
|
|
|
|
config.SnackbarConfiguration.NewestOnTop = false;
|
|
|
|
config.SnackbarConfiguration.ShowCloseIcon = true;
|
|
|
|
config.SnackbarConfiguration.VisibleStateDuration = 6_000; //milliseconds aka 6 seconds
|
|
|
|
config.SnackbarConfiguration.HideTransitionDuration = 500;
|
|
|
|
config.SnackbarConfiguration.ShowTransitionDuration = 500;
|
|
|
|
config.SnackbarConfiguration.SnackbarVariant = Variant.Outlined;
|
|
|
|
});
|
|
|
|
|
2024-04-05 20:23:36 +00:00
|
|
|
builder.Services.AddMudMarkdownServices();
|
2024-05-04 08:47:42 +00:00
|
|
|
builder.Services.AddSingleton<Rust>();
|
|
|
|
builder.Services.AddMudMarkdownClipboardService<MarkdownClipboardService>();
|
2024-04-05 20:23:36 +00:00
|
|
|
builder.Services.AddSingleton<SettingsManager>();
|
2024-05-04 08:49:09 +00:00
|
|
|
builder.Services.AddSingleton<Random>();
|
2024-03-28 21:26:48 +00:00
|
|
|
builder.Services.AddRazorComponents()
|
2024-04-05 14:16:33 +00:00
|
|
|
.AddInteractiveServerComponents()
|
|
|
|
.AddHubOptions(x =>
|
|
|
|
{
|
|
|
|
x.MaximumReceiveMessageSize = null;
|
|
|
|
});
|
|
|
|
|
2024-05-11 11:30:17 +00:00
|
|
|
var port = args.Length > 0 ? args[0] : "5000";
|
|
|
|
builder.WebHost.UseUrls($"http://localhost:{port}");
|
2024-03-28 21:26:48 +00:00
|
|
|
|
2024-05-18 19:50:46 +00:00
|
|
|
#if DEBUG
|
|
|
|
builder.WebHost.UseWebRoot("wwwroot");
|
|
|
|
builder.WebHost.UseStaticWebAssets();
|
|
|
|
#endif
|
|
|
|
|
2024-03-28 21:26:48 +00:00
|
|
|
var app = builder.Build();
|
2024-05-13 16:46:26 +00:00
|
|
|
app.Use(Redirect.HandlerContentAsync);
|
2024-05-18 19:50:46 +00:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
app.UseStaticFiles();
|
2024-05-18 20:40:48 +00:00
|
|
|
app.UseDeveloperExceptionPage();
|
2024-05-18 19:50:46 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
var fileProvider = new ManifestEmbeddedFileProvider(Assembly.GetAssembly(type: typeof(Program))!, "wwwroot");
|
2024-05-10 19:52:37 +00:00
|
|
|
app.UseStaticFiles(new StaticFileOptions
|
|
|
|
{
|
|
|
|
FileProvider = fileProvider,
|
|
|
|
RequestPath = string.Empty,
|
|
|
|
});
|
|
|
|
|
2024-05-18 19:50:46 +00:00
|
|
|
#endif
|
|
|
|
|
2024-03-28 21:26:48 +00:00
|
|
|
app.UseAntiforgery();
|
|
|
|
app.MapRazorComponents<App>()
|
|
|
|
.AddInteractiveServerRenderMode();
|
|
|
|
|
2024-05-12 12:32:34 +00:00
|
|
|
var serverTask = app.RunAsync();
|
|
|
|
|
|
|
|
Console.WriteLine("RUST/TAURI SERVER STARTED");
|
|
|
|
await serverTask;
|