forked from jsnbuchanan/crowd-funder-for-time-pwa
fix: update Vue template syntax and improve Vite config
- Fix Vue template syntax in App.vue by using proper event handler format - Update Vite config to properly handle ESM imports and crypto modules - Add manual chunks for better code splitting - Improve environment variable handling in vite-env.d.ts - Fix TypeScript linting errors in App.vue
This commit is contained in:
@@ -1,29 +1,38 @@
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
import { CapacitorQRScanner } from "./CapacitorQRScanner";
|
||||
import { WebQRScanner } from "./WebQRScanner";
|
||||
import type { QRScannerService } from "./types";
|
||||
import { logger } from "../../utils/logger";
|
||||
import { Capacitor } from '@capacitor/core'
|
||||
import { CapacitorQRScanner } from './CapacitorQRScanner'
|
||||
import type { QRScannerService } from './types'
|
||||
import { logger } from '../../utils/logger'
|
||||
import { WebDialogQRScanner } from './WebDialogQRScanner'
|
||||
|
||||
// Import platform-specific flags from Vite config
|
||||
declare const __USE_QR_READER__: boolean
|
||||
declare const __IS_MOBILE__: boolean
|
||||
|
||||
export class QRScannerFactory {
|
||||
private static instance: QRScannerService | null = null;
|
||||
private static instance: QRScannerService | null = null
|
||||
|
||||
static getInstance(): QRScannerService {
|
||||
if (!this.instance) {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
logger.log("Creating native QR scanner instance");
|
||||
this.instance = new CapacitorQRScanner();
|
||||
// Use platform-specific flags for more accurate detection
|
||||
if (__IS_MOBILE__ || Capacitor.isNativePlatform()) {
|
||||
logger.log('Creating native QR scanner instance')
|
||||
this.instance = new CapacitorQRScanner()
|
||||
} else if (__USE_QR_READER__) {
|
||||
logger.log('Creating web QR scanner instance')
|
||||
this.instance = new WebDialogQRScanner()
|
||||
} else {
|
||||
logger.log("Creating web QR scanner instance");
|
||||
this.instance = new WebQRScanner();
|
||||
throw new Error(
|
||||
'No QR scanner implementation available for this platform'
|
||||
)
|
||||
}
|
||||
}
|
||||
return this.instance;
|
||||
return this.instance
|
||||
}
|
||||
|
||||
static async cleanup() {
|
||||
if (this.instance) {
|
||||
await this.instance.cleanup();
|
||||
this.instance = null;
|
||||
await this.instance.cleanup()
|
||||
this.instance = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user