diff --git a/Program.cs b/Program.cs index 8b29c5e..708477a 100644 --- a/Program.cs +++ b/Program.cs @@ -6,8 +6,25 @@ using Front; using Front.Program.Services; using Front.Program.ViewModels; +const bool local = true; var builder = WebAssemblyHostBuilder.CreateDefault(args); +Func 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"); builder.RootComponents.Add("head::after"); @@ -15,19 +32,16 @@ builder.RootComponents.Add("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 { - // BaseAddress = new Uri("http://0.0.0.0:5144") - BaseAddress = new Uri("https://devacamate.ipstein.myds.me") - // BaseAddress = builder.HostEnvironment.IsDevelopment() - // ? new Uri("https://devacamate.ipstein.myds.me") - // : new Uri("https://acamate.ipstein.myds.me") - + // 서버 올릴때는 이 부분을 꼭 확인 할 것 + // true 면 로컬 / false 면 배포 + BaseAddress = checkLocal(local) }; return http; }); diff --git a/Program/Views/Academy/AcademyIntro.razor b/Program/Views/Academy/AcademyIntro.razor index e0a9321..f4a2397 100644 --- a/Program/Views/Academy/AcademyIntro.razor +++ b/Program/Views/Academy/AcademyIntro.razor @@ -35,7 +35,7 @@
@foreach (var academy in UserStateService.academyItems) { -
@academy.name diff --git a/Program/Views/Academy/AcademyIntro.razor.cs b/Program/Views/Academy/AcademyIntro.razor.cs index cfd347b..a27c3a7 100644 --- a/Program/Views/Academy/AcademyIntro.razor.cs +++ b/Program/Views/Academy/AcademyIntro.razor.cs @@ -48,22 +48,6 @@ public partial class AcademyIntro : ComponentBase, IDisposable await InvokeAsync(StateHasChanged); } // 유저 값 가져오면서 같이 academy 정보도 가져와야지 - - - - // academyItems = new[] - // { - // new SimpleAcademy{ bid = "AA0000", business_name = "테스트 학원1"}, - // new SimpleAcademy{ bid = "AA0001", business_name = "테스트 학원2"}, - // new SimpleAcademy{ bid = "AA0002", business_name = "테스트 학원3"}, - // new SimpleAcademy{ bid = "AA0003", business_name = "테스트 학원4"}, - // new SimpleAcademy{ bid = "AA0004", business_name = "테스트 학원5"}, - // new SimpleAcademy{ bid = "AA0005", business_name = "테스트 학원6"}, - // new SimpleAcademy{ bid = "AA0006", business_name = "테스트 학원7"}, - - // }; - - } public void Dispose() @@ -121,10 +105,6 @@ public partial class AcademyIntro : ComponentBase, IDisposable LoadingService.HideLoading(); _isProcessing = false; - // var baseUri = uri.GetLeftPart(UriPartial.Path); - // Console.WriteLine($"리다이렉트할 URI: {baseUri}"); - // await InvokeAsync(StateHasChanged); // StateHasChanged를 호출하여 UI 업데이트 - // Navigation.NavigateTo(baseUri, forceLoad: false); } } diff --git a/Program/Views/Academy/AcademyMain.razor.cs b/Program/Views/Academy/AcademyMain.razor.cs index 79abd35..dd3e921 100644 --- a/Program/Views/Academy/AcademyMain.razor.cs +++ b/Program/Views/Academy/AcademyMain.razor.cs @@ -1,7 +1,48 @@ +using Front.Program.Services; +using Front.Program.ViewModels; using Microsoft.AspNetCore.Components; namespace Front.Program.Views.Academy; public partial class AcademyMain : ComponentBase { + [Inject] private ILogger Logger { get; set; } = default!; + [Inject] NavigationManager Navigation { get; set; } = default!; + [Inject] UserStateService UserStateService { get; set; } = default!; + [Inject] QueryParamService QueryParamService { get; set; } = default!; + [Inject] StorageService StorageService { get; set; } = default!; + [Inject] LoadingService LoadingService { get; set; } = default!; + + protected override async Task OnInitializedAsync() + { + // 초기화 작업 + // await UserStateService.GetUserDataAsync(); + // if (UserStateService.isFirstCheck) + // { + // // 첫 번째 체크 후에만 Academy 정보를 가져옴 + // var academyResult = await UserStateService.GetAcademy(); + // + // if (academyResult.success && academyResult.simpleAcademy.Count > 0) + // { + // UserStateService.academyItems = academyResult.simpleAcademy.ToArray(); + // } + // } + // + // URL 파라미터 처리 + + var uri = Navigation.ToAbsoluteUri(Navigation.Uri); + Logger.LogDebug("DEBUG"); + Logger.LogError("ERROR"); + + + Console.WriteLine("쿼리 있나?"); + // 쿼리 파라미터가 있는 경우에만 처리 + if (!string.IsNullOrEmpty(uri.Query)) + { + var queryParam = QueryParamService.ParseQueryParam(uri); + Console.WriteLine($"Parsed Query Parameters: {string.Join(", ", queryParam.Select(kv => $"{kv.Key}={kv.Value}"))}"); + } + Console.WriteLine("쿼리 검사"); + + } } \ No newline at end of file