1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- @using Microsoft.JSInterop
- @using WarcViewerBlazorWinForm.Backend.Logging
- @implements IDisposable
- @inject ILogger<App> Logger
- @inject IJSRuntime JsRuntime
- @inject IEventBus EventBus
- <BootstrapBlazorRoot>
- <Tab IsCard IsOnlyRenderActiveTab class="h-100vh">
- <TabItem Text="Open Archive">
- <ArchiveView></ArchiveView>
- </TabItem>
- <TabItem Text="Indexer">
- <IndexerStatusLabel></IndexerStatusLabel>
- </TabItem>
- <TabItem Text="Viewer">
- <Split Basis="30%">
- <FirstPaneTemplate>
- <div class="d-flex justify-content-center align-items-center h-100">我是左侧面板</div>
- </FirstPaneTemplate>
- <SecondPaneTemplate>
- <div class="d-flex justify-content-center align-items-center h-100">我是右侧面板</div>
- </SecondPaneTemplate>
- </Split>
- </TabItem>
- </Tab>
- </BootstrapBlazorRoot>
- @code
- {
-
- protected override void OnInitialized()
- {
- base.OnInitialized();
- EventBus.Subscript<LoggingEvent>(HandleLogging);
- Logger.LogInformation("App UI started");
- }
- private void HandleLogging(LoggingEvent obj)
- {
- switch (obj.LogLevel)
- {
- case LogLevel.Debug:
- JsRuntime.InvokeVoidAsync("console.debug", obj.Content);
- break;
- case LogLevel.Information:
- JsRuntime.InvokeVoidAsync("console.info", obj.Content);
- break;
- case LogLevel.Warning:
- JsRuntime.InvokeVoidAsync("console.warn", obj.Content);
- break;
- case LogLevel.Critical:
- case LogLevel.Error:
- JsRuntime.InvokeVoidAsync("console.error", obj.Content);
- break;
- case LogLevel.Trace:
- case LogLevel.None:
- default:
- JsRuntime.InvokeVoidAsync("console.log", $"{obj.LogLevel} {obj.Content}");
- break;
- }
- }
- public void Dispose()
- {
- EventBus.UnSubscript<LoggingEvent>(HandleLogging);
- }
- }
|