update frontend
This commit is contained in:
parent
1144e87358
commit
e47daa2efb
|
|
@ -0,0 +1,47 @@
|
||||||
|
// src/pwaInstall.js
|
||||||
|
let deferredPrompt = null;
|
||||||
|
|
||||||
|
window.addEventListener('beforeinstallprompt', (e) => {
|
||||||
|
// Empêche le prompt par défaut
|
||||||
|
e.preventDefault();
|
||||||
|
deferredPrompt = e;
|
||||||
|
console.log('PWA install prompt ready');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fonction pour déclencher l’install (tu peux l’appeler sur un bouton)
|
||||||
|
export function promptInstall() {
|
||||||
|
if (deferredPrompt) {
|
||||||
|
deferredPrompt.prompt();
|
||||||
|
deferredPrompt.userChoice.then((choiceResult) => {
|
||||||
|
if (choiceResult.outcome === 'accepted') {
|
||||||
|
console.log('PWA installed');
|
||||||
|
} else {
|
||||||
|
console.log('PWA dismissed');
|
||||||
|
}
|
||||||
|
deferredPrompt = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajoute un bouton "Installer l’app" dans ton UI (optionnel)
|
||||||
|
export function addInstallButton() {
|
||||||
|
const btn = document.createElement('button');
|
||||||
|
btn.textContent = 'Installer SocioWire';
|
||||||
|
btn.style.position = 'fixed';
|
||||||
|
btn.style.bottom = '20px';
|
||||||
|
btn.style.right = '20px';
|
||||||
|
btn.style.padding = '10px 20px';
|
||||||
|
btn.style.background = '#0ea5e9';
|
||||||
|
btn.style.color = 'white';
|
||||||
|
btn.style.border = 'none';
|
||||||
|
btn.style.borderRadius = '8px';
|
||||||
|
btn.style.cursor = 'pointer';
|
||||||
|
btn.style.zIndex = '9999';
|
||||||
|
btn.onclick = promptInstall;
|
||||||
|
document.body.appendChild(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Détection si déjà installé (cache)
|
||||||
|
if (window.matchMedia('(display-mode: standalone)').matches || navigator.standalone) {
|
||||||
|
console.log('App already installed');
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
// src/pwaInstall.js
|
||||||
|
let deferredPrompt = null;
|
||||||
|
|
||||||
|
window.addEventListener('beforeinstallprompt', (e) => {
|
||||||
|
// Empêche le prompt par défaut
|
||||||
|
e.preventDefault();
|
||||||
|
deferredPrompt = e;
|
||||||
|
console.log('PWA install prompt ready');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fonction pour déclencher l’install (tu peux l’appeler sur un bouton)
|
||||||
|
export function promptInstall() {
|
||||||
|
if (deferredPrompt) {
|
||||||
|
deferredPrompt.prompt();
|
||||||
|
deferredPrompt.userChoice.then((choiceResult) => {
|
||||||
|
if (choiceResult.outcome === 'accepted') {
|
||||||
|
console.log('PWA installed');
|
||||||
|
} else {
|
||||||
|
console.log('PWA dismissed');
|
||||||
|
}
|
||||||
|
deferredPrompt = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajoute un bouton "Installer l’app" dans ton UI (optionnel)
|
||||||
|
export function addInstallButton() {
|
||||||
|
const btn = document.createElement('button');
|
||||||
|
btn.textContent = 'Installer SocioWire';
|
||||||
|
btn.style.position = 'fixed';
|
||||||
|
btn.style.bottom = '20px';
|
||||||
|
btn.style.right = '20px';
|
||||||
|
btn.style.padding = '10px 20px';
|
||||||
|
btn.style.background = '#0ea5e9';
|
||||||
|
btn.style.color = 'white';
|
||||||
|
btn.style.border = 'none';
|
||||||
|
btn.style.borderRadius = '8px';
|
||||||
|
btn.style.cursor = 'pointer';
|
||||||
|
btn.style.zIndex = '9999';
|
||||||
|
btn.onclick = promptInstall;
|
||||||
|
document.body.appendChild(btn);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Détection si déjà installé (cache)
|
||||||
|
if (window.matchMedia('(display-mode: standalone)').matches || navigator.standalone) {
|
||||||
|
console.log('App already installed');
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue