fix: restore and stabilize tab navigation with Alpine.js
- Fixed navigation blockage by moving Alpine state to body scope - Resolved CSS display conflicts between legacy .active class and x-show - Synchronized legacy auth logic with Alpine global state - Redirected legacy switchTab calls to Alpine events - Removed obsolete tabs.js and updated home section initialization - Added E2E navigation test placeholder
This commit is contained in:
+16
-3
@@ -91,14 +91,27 @@ async function checkAuth() {
|
||||
|
||||
if (response.ok) {
|
||||
const data = await response.json();
|
||||
|
||||
|
||||
// Log for debugging
|
||||
console.log('Auth check successful for:', data.user.username);
|
||||
|
||||
// Dispatch event for Alpine.js global state
|
||||
window.dispatchEvent(new CustomEvent('auth-success', {
|
||||
detail: { username: data.user.full_name || data.user.username }
|
||||
}));
|
||||
|
||||
|
||||
// Set global auth state in case dispatch was too early
|
||||
if (window.Alpine) {
|
||||
const body = document.querySelector('body');
|
||||
if (body && body.__x) {
|
||||
body.__x.$data.isAuthenticated = true;
|
||||
body.__x.$data.username = data.user.full_name || data.user.username;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Token invalid, remove it and redirect
|
||||
removeToken();
|
||||
redirectToLogin();
|
||||
|
||||
Reference in New Issue
Block a user