| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import { Component, PropsWithChildren } from 'react'
- import './app.scss'
- import '@/context/locales/index'
- import { Provider } from 'react-redux'
- import store from './store/store'
- import { View } from '@tarojs/components'
- import GlobalModal from './components/layout/GlobalModal'
- import Taro from '@tarojs/taro'
- // import { StatusBar } from 'react-native'
- // import jgPush from './utils/push.rn'
- // import 'taro-ui/dist/style/index.scss'
- let LogBox;
- let StatusBar;
- if (process.env.TARO_ENV == 'rn') {
- LogBox = require("react-native").LogBox
- StatusBar = require("react-native").StatusBar
- }
- const App: React.FC<PropsWithChildren> = ({ children }) => {
- if (process.env.TARO_ENV=='rn'){
- // alert(Intl.DateTimeFormat().resolvedOptions().timeZone)
- }
- if (process.env.TARO_ENV == 'weapp') {
- global.isDebug = Taro.getStorageSync('isDebug')
- const updateManager = Taro.getUpdateManager()
- updateManager.onUpdateReady(function () {
- Taro.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- showCancel: false,
- success: function (res) {
- if (res.confirm) {
- updateManager.applyUpdate();
- }
- }
- });
- });
- updateManager.onUpdateFailed(function () {
- // 新版本下载失败
- Taro.showModal({
- title: '已经有新版本喽~',
- content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~',
- showCancel: false,
- });
- });
- }
- else {
- //关闭其中某些yellow警告
- LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
- LogBox.ignoreAllLogs();//Ignore all log notifications
- const test = require('./utils/push').default
- test()
- // jgPush()
- // const JPush = require('jpush-react-native')
- // JPush.init({ appKey: "4fcc3e237eec4c4fb804ad49", channel: "dev", production: false });
- // //连接状态
- // JPush.addConnectEventListener(result => {
- // console.log(result)
- // debugger
- // })
- // console.log('rn jpush init')
- // //通知回调
- // var notificationListener = result => {
- // console.log("notificationListener:" + JSON.stringify(result))
- // alert(JSON.stringify(result))
- // };
- // JPush.addNotificationListener(notificationListener);
- // //本地通知回调
- // var localNotificationListener = result => {
- // console.log("localNotificationListener:" + JSON.stringify(result))
- // };
- // JPush.addLocalNotificationListener(localNotificationListener);
- // //自定义消息回调
- // var customMessageListener = result => {
- // console.log("customMessageListener:" + JSON.stringify(result))
- // };
- // JPush.addCustomMessageListener(customMessageListener);
- // //应用内消息回调
- // JPush.pageEnterTo("HomePage") // 进入首页,当页面退出时请调用 JPush.pageLeave('HomePage')
- // var inappMessageListener = result => {
- // console.log("inappMessageListener:" + JSON.stringify(result))
- // alert(JSON.stringify(result))
- // };
- // JPush.addInappMessageListener(inappMessageListener);
- // //tag alias事件回调
- // var tagAliasListener = result => {
- // console.log("tagAliasListener:" + JSON.stringify(result))
- // };
- // JPush.addTagAliasListener(tagAliasListener);
- // //手机号码事件回调
- // var mobileNumberListener = result => {
- // console.log("mobileNumberListener:" + JSON.stringify(result))
- // };
- // JPush.addMobileNumberListener(mobileNumberListener);
- }
- return <Provider store={store}>
- {process.env.TARO_ENV == 'rn' && <StatusBar barStyle='light-content' />}
- {children}
- </Provider>
- }
- // class App extends Component<PropsWithChildren> {
- // componentDidMount () {}
- // componentDidShow () {}
- // componentDidHide () {}
- // // this.props.children 是将要会渲染的页面
- // render () {
- // return this.props.children
- // }
- // }
- export default App
|