feat: PWA support - manifest, service worker, icons

This commit is contained in:
2026-05-26 15:50:29 +00:00
parent f42bb49360
commit d4a5046826
5 changed files with 117 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

+23
View File
@@ -3,6 +3,15 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#10a37f">
<meta name="description" content="Assistente virtual da Camila - Profesora">
<!-- PWA Manifest -->
<link rel="manifest" href="/manifest.json">
<!-- iOS PWA Support -->
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="Camila AI">
<link rel="apple-touch-icon" href="/icon-192.png">
<title>Camila AI</title>
<!-- Google Fonts Outfit & Inter -->
<link rel="preconnect" href="https://fonts.googleapis.com">
@@ -202,5 +211,19 @@
<script>
document.write('<script src="app.js?v=' + Date.now() + '"><\/script>');
</script>
<!-- Service Worker Registration for PWA -->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then((registration) => {
console.log('Camila AI SW registered:', registration.scope);
})
.catch((error) => {
console.log('Camila AI SW registration failed:', error);
});
});
}
</script>
</body>
</html>
+26
View File
@@ -0,0 +1,26 @@
{
"name": "Camila AI",
"short_name": "Camila",
"description": "Assistente virtual da Camila",
"start_url": "/",
"display": "standalone",
"background_color": "#0a0a0a",
"theme_color": "#10a37f",
"orientation": "portrait-primary",
"icons": [
{
"src": "/icon-192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "any maskable"
},
{
"src": "/icon-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "any maskable"
}
],
"categories": ["education", "productivity"],
"lang": "pt-BR"
}
+68
View File
@@ -0,0 +1,68 @@
const CACHE_NAME = 'camila-ai-v1';
const urlsToCache = [
'/',
'/index.html',
'/style.css',
'/app.js',
'/manifest.json',
'/icon-192.png',
'/icon-512.png'
];
// Install event - cache assets
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => {
console.log('Camila AI: Cache opened');
return cache.addAll(urlsToCache);
})
.then(() => self.skipWaiting())
);
});
// Activate event - clean old caches
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
console.log('Camila AI: Deleting old cache:', cacheName);
return caches.delete(cacheName);
}
})
);
}).then(() => self.clients.claim())
);
});
// Fetch event - serve from cache, fallback to network
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((response) => {
if (response) {
return response;
}
return fetch(event.request).then((response) => {
// Don't cache non-successful responses or non-GET requests
if (!response || response.status !== 200 || event.request.method !== 'GET') {
return response;
}
// Clone the response
const responseToCache = response.clone();
caches.open(CACHE_NAME).then((cache) => {
cache.put(event.request, responseToCache);
});
return response;
});
})
.catch(() => {
// If both cache and network fail, show offline page for HTML requests
if (event.request.headers.get('accept').includes('text/html')) {
return caches.match('/');
}
})
);
});