Fix: Loading screen now waits for Blazor.start() on all pages
Problem: - Loading screen was hiding immediately without waiting for Blazor - Page detection logic was too restrictive (only /blazor paths) - Most admin pages don't have Blazor components, so screen hid instantly Solution: - Blazor Server is loaded on ALL admin pages via _Layout.cshtml - Removed restrictive path checking (was checking for /blazor or components) - Now always calls Blazor.start() and waits for SignalR connection - Loading screen properly shows while SignalR establishes connection Expected behavior: - First load: Screen shows → Blazor connects → Screen fades out - Console: "Starting Blazor Server..." → "Started successfully" → "Hiding" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
db2443c7ac
commit
0a08d1a943
@ -11,43 +11,37 @@ document.addEventListener('DOMContentLoaded', async function() {
|
||||
console.log('Blazor: Showing loading screen for first load');
|
||||
}
|
||||
|
||||
// Check if we're on a page that should use Blazor
|
||||
const blazorContainers = document.querySelectorAll('[data-blazor-component]');
|
||||
// Blazor Server is available on all Admin pages, so always start it
|
||||
// The blazor.server.js script is already loaded in _Layout.cshtml
|
||||
try {
|
||||
console.log('Blazor: Starting Blazor Server...');
|
||||
|
||||
if (blazorContainers.length > 0 || window.location.pathname.includes('/Admin/Products/Blazor') || window.location.pathname.includes('/blazor')) {
|
||||
try {
|
||||
console.log('Blazor: Starting Blazor Server...');
|
||||
|
||||
// Start Blazor Server with reconnection UI
|
||||
await Blazor.start({
|
||||
reconnectionOptions: {
|
||||
maxRetries: 8,
|
||||
retryIntervalMilliseconds: 2000
|
||||
// Start Blazor Server with reconnection UI
|
||||
await Blazor.start({
|
||||
reconnectionOptions: {
|
||||
maxRetries: 8,
|
||||
retryIntervalMilliseconds: 2000
|
||||
},
|
||||
reconnectionHandler: {
|
||||
onConnectionDown: () => {
|
||||
console.log('Blazor: Connection lost, attempting to reconnect...');
|
||||
showReconnectingUI();
|
||||
},
|
||||
reconnectionHandler: {
|
||||
onConnectionDown: () => {
|
||||
console.log('Blazor: Connection lost, attempting to reconnect...');
|
||||
showReconnectingUI();
|
||||
},
|
||||
onConnectionUp: () => {
|
||||
console.log('Blazor: Reconnected successfully');
|
||||
hideReconnectingUI();
|
||||
}
|
||||
onConnectionUp: () => {
|
||||
console.log('Blazor: Reconnected successfully');
|
||||
hideReconnectingUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Blazor: Started successfully');
|
||||
console.log('Blazor: Started successfully');
|
||||
|
||||
// Mark as loaded and hide loading screen
|
||||
sessionStorage.setItem('blazorLoaded', 'true');
|
||||
hideLoadingScreen();
|
||||
// Mark as loaded and hide loading screen
|
||||
sessionStorage.setItem('blazorLoaded', 'true');
|
||||
hideLoadingScreen();
|
||||
|
||||
} catch (error) {
|
||||
console.error('Blazor: Failed to start:', error);
|
||||
hideLoadingScreen();
|
||||
}
|
||||
} else {
|
||||
// Not a Blazor page, hide loading screen immediately
|
||||
} catch (error) {
|
||||
console.error('Blazor: Failed to start:', error);
|
||||
hideLoadingScreen();
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user