import { useEffect, PropsWithChildren } from 'react'; import Taro from '@tarojs/taro'; import ErrorBoundary from './components/ErrorBoundary'; import { flushEvents } from './services/analytics'; import { useAuthStore } from './stores/auth'; import './app.scss'; function App({ children }: PropsWithChildren>) { const restoreAuth = useAuthStore((s) => s.restore); useEffect(() => { restoreAuth(); const timer = setInterval(() => { flushEvents(); }, 30000); const onHide = () => { flushEvents(); }; Taro.eventCenter.on('appHide', onHide); return () => { clearInterval(timer); Taro.eventCenter.off('appHide', onHide); }; }, []); return {children}; } export default App;