feat: Add PWA support and consolidate CSS design system
- Add PWA manifest, icons (192x192, 512x512), and service worker - Register service worker in index.html with Apple mobile web app support - Consolidate CSS variables and design tokens documentation - Update PrimeVue overrides for consistent theming - Refactor data-entry components to use shared CSS patterns - Add frontend-style-auditor agent for style consistency checks - Minor OCR validation and job worker improvements - Update start-prod.sh configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
62
public/sw.js
Normal file
62
public/sw.js
Normal file
@@ -0,0 +1,62 @@
|
||||
// Service Worker for ROA2WEB PWA
|
||||
// Network-first strategy to always show fresh content
|
||||
|
||||
const CACHE_VERSION = 'v2';
|
||||
const CACHE_NAME = `roa2web-${CACHE_VERSION}`;
|
||||
|
||||
// Install event - skip waiting to activate immediately
|
||||
self.addEventListener('install', (event) => {
|
||||
console.log('[SW] Installing service worker...');
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
// Activate event - clear old caches and claim clients
|
||||
self.addEventListener('activate', (event) => {
|
||||
console.log('[SW] Service worker activated');
|
||||
event.waitUntil(
|
||||
Promise.all([
|
||||
// Clear all old caches
|
||||
caches.keys().then(cacheNames => {
|
||||
return Promise.all(
|
||||
cacheNames.map(cacheName => {
|
||||
if (cacheName !== CACHE_NAME) {
|
||||
console.log('[SW] Deleting old cache:', cacheName);
|
||||
return caches.delete(cacheName);
|
||||
}
|
||||
})
|
||||
);
|
||||
}),
|
||||
// Take control of all clients immediately
|
||||
clients.claim()
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
// Fetch event - ALWAYS network first, no caching for HTML/JS/CSS
|
||||
self.addEventListener('fetch', (event) => {
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
// Skip non-GET requests
|
||||
if (event.request.method !== 'GET') {
|
||||
return;
|
||||
}
|
||||
|
||||
// API calls - always network, no cache
|
||||
if (url.pathname.includes('/api/')) {
|
||||
event.respondWith(fetch(event.request));
|
||||
return;
|
||||
}
|
||||
|
||||
// HTML, JS, CSS - always fetch fresh from network
|
||||
// This ensures PWA always loads latest version
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
.then(response => {
|
||||
return response;
|
||||
})
|
||||
.catch(() => {
|
||||
// Only fallback to cache if network fails
|
||||
return caches.match(event.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user