import { useEffect } from 'react' import type { PropsWithChildren } from 'react' import { useDidHide, useDidShow, useLaunch } from '@tarojs/taro' import { flush, trackAppLaunch } from './utils/track' import { loadRemoteConfig, softRefreshRemoteConfig, startRemoteConfigLiveSync, } from './services/remoteConfig' import { startH5RemLock } from './utils/h5RemLock' import { applyH5Theme, getStoredH5Theme } from './utils/h5Theme' // Taro multi-end: theme.h5.ts -> community.scss; theme.ts -> h5-theme.scss import './styles/theme' import './styles/ebook.scss' import './app.scss' function App({ children }: PropsWithChildren) { useLaunch(() => { trackAppLaunch() void loadRemoteConfig(true) if (process.env.TARO_ENV === 'h5') { applyH5Theme(getStoredH5Theme()) } }) useDidShow(() => { softRefreshRemoteConfig() }) useDidHide(() => { void flush() }) useEffect(() => { const stopRem = startH5RemLock() const stopLive = startRemoteConfigLiveSync() if (process.env.TARO_ENV === 'h5') { applyH5Theme(getStoredH5Theme()) } return () => { stopRem() stopLive() } }, []) return children } export default App