forked from AcaMate/AcaMate_Web
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Front;
|
|
using Front.Program.Services;
|
|
using Front.Program.ViewModels;
|
|
|
|
const bool local = true;
|
|
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
|
|
|
Func<bool, Uri> checkLocal = (isLocal) =>
|
|
{
|
|
if (isLocal) return new Uri("http://0.0.0.0:5144");
|
|
else return builder.HostEnvironment.IsDevelopment() ? new Uri("https://devacamate.ipstein.myds.me") : new Uri("https://acamate.ipstein.myds.me");
|
|
};
|
|
|
|
|
|
if (local)
|
|
{
|
|
builder.Logging.SetMinimumLevel(LogLevel.Debug);
|
|
}
|
|
else
|
|
{
|
|
builder.Logging.SetMinimumLevel(builder.HostEnvironment.IsDevelopment() ? LogLevel.Debug: LogLevel.Warning);
|
|
}
|
|
|
|
builder.RootComponents.Add<App>("#app");
|
|
builder.RootComponents.Add<HeadOutlet>("head::after");
|
|
|
|
// 설정 파일 로드
|
|
// builder.Configuration.AddJsonFile("appsettings.json", optional: false);
|
|
builder.Configuration.AddJsonFile($"appsettings.{builder.HostEnvironment.Environment}.json", optional: true);
|
|
|
|
|
|
|
|
builder.Services.AddScoped(sp => //new HttpClient
|
|
{
|
|
var config = builder.Configuration;
|
|
var http = new HttpClient
|
|
{
|
|
// 서버 올릴때는 이 부분을 꼭 확인 할 것
|
|
// true 면 로컬 / false 면 배포
|
|
BaseAddress = checkLocal(local)
|
|
};
|
|
return http;
|
|
});
|
|
|
|
// SCOPED 으로 등록된 서비스는 DI 컨테이너에 등록된 서비스의 인스턴스를 사용합니다.
|
|
builder.Services.AddScoped<APIService>();
|
|
builder.Services.AddScoped<SecureService>();
|
|
builder.Services.AddScoped<StorageService>();
|
|
builder.Services.AddScoped<QueryParamService>();
|
|
|
|
builder.Services.AddScoped<LoadingService>();
|
|
builder.Services.AddScoped<UserStateService>();
|
|
|
|
await builder.Build().RunAsync();
|