-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
37 lines (34 loc) · 984 Bytes
/
Copy pathindex.tsx
File metadata and controls
37 lines (34 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import ReactDOM from 'react-dom/client';
import AppRouter from './Router';
import { CacheProvider } from './contexts/CacheContext';
import { registerSW } from 'virtual:pwa-register';
// Registrar Service Worker para PWA
const updateSW = registerSW({
onNeedRefresh() {
if (confirm('Nova versão disponível! Deseja atualizar?')) {
updateSW(true);
}
},
onOfflineReady() {
console.log('✅ App pronto para uso offline!');
},
onRegistered(registration) {
console.log('✅ Service Worker registrado!', registration);
},
onRegisterError(error) {
console.error('❌ Erro ao registrar Service Worker:', error);
}
});
const rootElement = document.getElementById('root');
if (!rootElement) {
throw new Error("Could not find root element to mount to");
}
const root = ReactDOM.createRoot(rootElement);
root.render(
<React.StrictMode>
<CacheProvider>
<AppRouter />
</CacheProvider>
</React.StrictMode>
);