fix: use global Capacitor object to hide splash screen (no package import)

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy 2026-06-18 21:30:29 +07:00
parent 4b61b14d36
commit dc66ac993f

View file

@ -8,11 +8,12 @@ import App from './App.tsx';
import './index.css';
// Hide Capacitor splash screen once JS is ready
// Must be called manually when autoHide: false (or as a safety net)
// Uses the global Capacitor object to avoid a hard dependency on the package
if (typeof window !== 'undefined') {
import('@capacitor/splash-screen').then(({ SplashScreen }) => {
SplashScreen.hide().catch(() => {/* not in Capacitor context */});
}).catch(() => {/* web build - no Capacitor */});
const cap = (window as unknown as { Capacitor?: { Plugins?: { SplashScreen?: { hide: () => Promise<void> } } } }).Capacitor;
if (cap?.Plugins?.SplashScreen) {
cap.Plugins.SplashScreen.hide().catch(() => {});
}
}
// Outfit font for body text