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:
parent
4b61b14d36
commit
dc66ac993f
1 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue