Fix: detection navigation SPA pour page team
This commit is contained in:
@@ -2,14 +2,27 @@
|
|||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// Fonction pour verifier si on est sur la route team
|
||||||
|
function isTeamRoute() {
|
||||||
var path = window.location.pathname;
|
var path = window.location.pathname;
|
||||||
var isTeamRoute = path === '/team' || path === '/team/' || path.startsWith('/team/');
|
return path === '/team' || path === '/team/' || path.startsWith('/team/');
|
||||||
|
}
|
||||||
|
|
||||||
if (!isTeamRoute) {
|
// Fonction pour verifier et initialiser la page team
|
||||||
|
function checkAndInitTeamPage() {
|
||||||
|
if (!isTeamRoute()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Eviter double initialisation
|
||||||
|
if (window.__teamPageInitialized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.__teamPageInitialized = true;
|
||||||
|
|
||||||
console.log('EQUIPE: Page team detectee, preparation du remplacement DOM');
|
console.log('EQUIPE: Page team detectee, preparation du remplacement DOM');
|
||||||
|
initTeamPage();
|
||||||
|
}
|
||||||
|
|
||||||
// Fonction pour charger un script externe
|
// Fonction pour charger un script externe
|
||||||
function loadScript(src) {
|
function loadScript(src) {
|
||||||
@@ -321,8 +334,18 @@
|
|||||||
|
|
||||||
// Demarrer quand le DOM est pret
|
// Demarrer quand le DOM est pret
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
document.addEventListener('DOMContentLoaded', initTeamPage);
|
document.addEventListener('DOMContentLoaded', checkAndInitTeamPage);
|
||||||
} else {
|
} else {
|
||||||
initTeamPage();
|
checkAndInitTeamPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detecter les navigations Next.js (SPA)
|
||||||
|
var lastUrl = location.href;
|
||||||
|
new MutationObserver(function() {
|
||||||
|
if (location.href !== lastUrl) {
|
||||||
|
lastUrl = location.href;
|
||||||
|
window.__teamPageInitialized = false;
|
||||||
|
checkAndInitTeamPage();
|
||||||
|
}
|
||||||
|
}).observe(document, { subtree: true, childList: true });
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user