App.tsx 1.42 KB
/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React, { useLayoutEffect, useEffect } from 'react'
import { StatusBar, Platform, Text, TextInput } from 'react-native'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import { RouterView } from './src/router'
import { Provider } from 'react-redux'
import { PrivacyAlert } from './src/components'
import { PortalHot, Update } from 'react-native-mb-ui'
import { getVersionCode } from './src/libs/utils'
import { APP } from './src/config'
import SplashScreen from 'react-native-splash-screen'
import store from './src/store'


//阻止系统缩放
TextInput.defaultProps = Object.assign({}, TextInput.defaultProps, { allowFontScaling: false })
Text.defaultProps = Object.assign({}, Text.defaultProps, { allowFontScaling: false })


const Page = () => {
  useLayoutEffect(() => {
    SplashScreen.hide()
  }, [])

  useEffect(() => {
    (async () => Update(`${APP.appAdminUrl}/api/app/version/${APP.APP_CODE}`, await getVersionCode()))()
  }, [])

  return (

    <Provider store={store}>
      {Platform.OS === 'ios' && <StatusBar translucent={true} backgroundColor="rgba(255,255,255,0)" barStyle="dark-content" />}
        <PortalHot>
          <SafeAreaProvider>
            <RouterView />
            <PrivacyAlert />
          </SafeAreaProvider>
        </PortalHot>
    </Provider>
  )
}

export default Page