feat: integrate PWA functionality with platform service architecture
- Add PWA methods to PlatformService interface (registerServiceWorker, isPWAEnabled) - Implement PWA logic in WebPlatformService with service worker registration - Add no-op PWA implementations for Capacitor and Electron platforms - Create PWAInstallPrompt component with custom install UI and event handling - Integrate PWA components into App.vue with platform-aware conditional rendering - Ensure PWA features only load on web platform via platform service pattern - Centralize PWA logic in platform service for consistent cross-platform behavior - Add comprehensive PWA documentation and installation flow support Platform service now handles all PWA operations including service worker registration, install prompts, and platform-specific feature detection.
This commit is contained in:
@@ -154,4 +154,15 @@ export interface PlatformService {
|
||||
* @returns Promise resolving to the first row as an array, or undefined if no results
|
||||
*/
|
||||
dbGetOneRow(sql: string, params?: unknown[]): Promise<unknown[] | undefined>;
|
||||
|
||||
// --- PWA/Web-only methods (optional, only implemented on web) ---
|
||||
/**
|
||||
* Registers the service worker for PWA support (web only)
|
||||
*/
|
||||
registerServiceWorker?(): void;
|
||||
|
||||
/**
|
||||
* Returns true if PWA is enabled (web only)
|
||||
*/
|
||||
readonly isPWAEnabled?: boolean;
|
||||
}
|
||||
|
||||
@@ -1299,4 +1299,8 @@ export class CapacitorPlatformService implements PlatformService {
|
||||
isWeb(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- PWA/Web-only methods (no-op for Capacitor) ---
|
||||
public registerServiceWorker(): void {}
|
||||
public get isPWAEnabled(): boolean { return false; }
|
||||
}
|
||||
|
||||
@@ -163,4 +163,8 @@ export class ElectronPlatformService extends CapacitorPlatformService {
|
||||
isWeb(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
// --- PWA/Web-only methods (no-op for Electron) ---
|
||||
public registerServiceWorker(): void {}
|
||||
public get isPWAEnabled(): boolean { return false; }
|
||||
}
|
||||
|
||||
@@ -645,6 +645,17 @@ export class WebPlatformService implements PlatformService {
|
||||
throw new Error("Camera rotation not implemented in web platform");
|
||||
}
|
||||
|
||||
// --- PWA/Web-only methods ---
|
||||
public registerServiceWorker(): void {
|
||||
if (this.isPWAEnabled) {
|
||||
import("@/registerServiceWorker");
|
||||
}
|
||||
}
|
||||
|
||||
public get isPWAEnabled(): boolean {
|
||||
return process.env.VITE_PWA_ENABLED === "true";
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if running in a worker context
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user