yeah
All checks were successful
Deploy App / build (push) Successful in 10s
Deploy App / deploy (push) Successful in 11s

This commit is contained in:
valere
2026-02-02 21:00:28 +01:00
parent e257e076c4
commit b9a3d0184f
98 changed files with 5068 additions and 3713 deletions

52
utils/tabManager.ts Normal file
View File

@@ -0,0 +1,52 @@
// Gestionnaire d'onglets pour les cartes NFC
export function openOrFocusCard(slug: string) {
const url = `${window.location.origin}/card/${slug}`
// Vérifier si un onglet est déjà ouvert
const isTabOpen = localStorage.getItem('nfc-active-tab') === 'true'
if (isTabOpen) {
// Si un onglet est déjà ouvert, on envoie un message pour le rafraîchir
const channel = new BroadcastChannel('nfc-channel')
channel.postMessage({
type: 'nfc-focus',
slug: slug,
timestamp: Date.now()
})
// On se concentre sur l'onglet existant
window.focus()
// On ferme le canal après un court délai
setTimeout(() => channel.close(), 1000)
// On empêche l'ouverture d'un nouvel onglet
return false
}
// Aucun onglet ouvert, on en ouvre un nouveau
window.open(url, '_blank')
return true
}
// Fonction pour formater l'URL à utiliser dans la carte NFC
export function getNfcCardUrl(slug: string): string {
return `javascript:(function(){
const url = '${window.location.origin}/card/${slug}';
const isTabOpen = localStorage.getItem('nfc-active-tab') === 'true';
if (isTabOpen) {
const channel = new BroadcastChannel('nfc-channel');
channel.postMessage({
type: 'nfc-focus',
slug: '${slug}',
timestamp: Date.now()
});
setTimeout(() => channel.close(), 1000);
window.focus();
window.location.href = url;
} else {
window.open(url, '_blank');
}
})();`
}