Skip to content

Commit ef7b9dc

Browse files
fix: seo problem and white flash screen
1 parent 651712d commit ef7b9dc

3 files changed

Lines changed: 42 additions & 50 deletions

File tree

src/2-Clients/WebApp/Pages/Website/Shared/WebsiteLayout.razor

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,31 @@
99
<link href="css/cb.website.spa.@(LocalizationSettings.GetCurrentLanguageDirection().ToLower()).min.css" rel="stylesheet" />
1010
</HeadContent>
1111

12-
<SplashScreen BrandName="@ApplicationSettings.Localized.Name" BackgroundCssClass="simple-layout-dark-bg" ProgressBarCssClass="simple-layout-title-color" OnStarted="HandleSplashStarted" />
13-
14-
@if (SplashScreenStarted)
15-
{
16-
<div class="website-wrapper">
17-
<BlazoredToasts Position="ToastPosition.BottomCenter"
18-
Timeout="5"
19-
IconType="IconType.Material"
20-
ErrorIcon=""
21-
InfoIcon=""
22-
SuccessIcon=""
23-
WarningIcon=""
24-
ShowProgressBar="true" />
25-
26-
<NavMenu />
27-
28-
<main>
29-
@Body
30-
</main>
31-
32-
<Footer />
33-
34-
@if (SettingAccessorService.Settings.AIChatBot.ShowChatBotWidgetOnWebsite)
35-
{
36-
<div class="chat-widget">
37-
<ChatBotWidget Theme="ChatBotWidgetTheme.Dark" />
38-
</div>
39-
}
40-
</div>
41-
42-
}
43-
44-
@code {
45-
/// <summary>
46-
/// Controls whether the splash screen has finished and the main content should be displayed.
47-
/// This demonstrates how to implement a loading state for better user experience.
48-
/// </summary>
49-
bool SplashScreenStarted = false;
50-
51-
/// <summary>
52-
/// Event handler called when the splash screen animation completes.
53-
/// Sets the flag to show the main website content and hide the splash screen.
54-
/// This demonstrates how to handle component lifecycle events in Blazor.
55-
/// </summary>
56-
private void HandleSplashStarted()
12+
<SplashScreen BrandName="@ApplicationSettings.Localized.Name" BackgroundCssClass="simple-layout-dark-bg" ProgressBarCssClass="simple-layout-title-color" />
13+
14+
<div id="main-layout-wrapper" class="website-wrapper">
15+
<BlazoredToasts Position="ToastPosition.BottomCenter"
16+
Timeout="5"
17+
IconType="IconType.Material"
18+
ErrorIcon=""
19+
InfoIcon=""
20+
SuccessIcon=""
21+
WarningIcon=""
22+
ShowProgressBar="true" />
23+
24+
<NavMenu />
25+
26+
<main>
27+
@Body
28+
</main>
29+
30+
<Footer />
31+
32+
@if (SettingAccessorService.Settings.AIChatBot.ShowChatBotWidgetOnWebsite)
5733
{
58-
SplashScreenStarted = true;
34+
<div class="chat-widget">
35+
<ChatBotWidget Theme="ChatBotWidgetTheme.Dark" />
36+
</div>
5937
}
60-
}
38+
39+
</div>

src/2-Clients/WebApp/Pages/_Host.cshtml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020
<base href="~/" />
2121
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
2222
</head>
23-
<body style="font-family: @LocalizationSettings.GetCurrentLanguageFont() !important">
23+
<body style="background-color:#362e6f; font-family: @LocalizationSettings.GetCurrentLanguageFont() !important;">
2424

2525
<component type="typeof(App)" render-mode="ServerPrerendered" />
2626

27-
<component type="typeof(ConnectionState)" render-mode="ServerPrerendered" />
28-
2927
<script src="js/cb.webapp.spa.min.js"></script>
3028
<script src="_framework/blazor.server.js"></script>
3129
</body>

src/2-Clients/WebApp/wwwroot/website/js/app.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,18 @@ document.addEventListener('DOMContentLoaded', function() {
166166
};
167167
});
168168

169+
// to remove the white flash screen on page load by hiding the main-layout-wrapper tag and showing it after 1 second
170+
// during this time the splash screen will be visible
171+
window.addEventListener("DOMContentLoaded", () => {
172+
173+
const websiteWrapper = document.getElementById('main-layout-wrapper');
174+
if (websiteWrapper) {
175+
// Hide immediately
176+
websiteWrapper.style.display = "none";
177+
178+
// Remove style after 1 second
179+
setTimeout(() => {
180+
websiteWrapper.removeAttribute('style');
181+
}, 1000);
182+
}
183+
});

0 commit comments

Comments
 (0)