app.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import { Component, PropsWithChildren } from 'react'
  2. import './app.scss'
  3. import '@/context/locales/index'
  4. import { Provider } from 'react-redux'
  5. import store from './store/store'
  6. import { View } from '@tarojs/components'
  7. import GlobalModal from './components/layout/GlobalModal'
  8. import Taro from '@tarojs/taro'
  9. // import { StatusBar } from 'react-native'
  10. // import jgPush from './utils/push.rn'
  11. // import 'taro-ui/dist/style/index.scss'
  12. let LogBox;
  13. let StatusBar;
  14. if (process.env.TARO_ENV == 'rn') {
  15. LogBox = require("react-native").LogBox
  16. StatusBar = require("react-native").StatusBar
  17. }
  18. const App: React.FC<PropsWithChildren> = ({ children }) => {
  19. console.log(Intl.DateTimeFormat().resolvedOptions().timeZone)
  20. if (process.env.TARO_ENV=='rn'){
  21. alert(Intl.DateTimeFormat().resolvedOptions().timeZone)
  22. }
  23. if (process.env.TARO_ENV == 'weapp') {
  24. global.isDebug = Taro.getStorageSync('isDebug')
  25. const updateManager = Taro.getUpdateManager()
  26. updateManager.onUpdateReady(function () {
  27. Taro.showModal({
  28. title: '更新提示',
  29. content: '新版本已经准备好,是否重启应用?',
  30. showCancel: false,
  31. success: function (res) {
  32. if (res.confirm) {
  33. updateManager.applyUpdate();
  34. }
  35. }
  36. });
  37. });
  38. updateManager.onUpdateFailed(function () {
  39. // 新版本下载失败
  40. Taro.showModal({
  41. title: '已经有新版本喽~',
  42. content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~',
  43. showCancel: false,
  44. });
  45. });
  46. }
  47. else {
  48. //关闭其中某些yellow警告
  49. LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
  50. LogBox.ignoreAllLogs();//Ignore all log notifications
  51. const test = require('./utils/push').default
  52. test()
  53. // jgPush()
  54. // const JPush = require('jpush-react-native')
  55. // JPush.init({ appKey: "4fcc3e237eec4c4fb804ad49", channel: "dev", production: false });
  56. // //连接状态
  57. // JPush.addConnectEventListener(result => {
  58. // console.log(result)
  59. // debugger
  60. // })
  61. // console.log('rn jpush init')
  62. // //通知回调
  63. // var notificationListener = result => {
  64. // console.log("notificationListener:" + JSON.stringify(result))
  65. // alert(JSON.stringify(result))
  66. // };
  67. // JPush.addNotificationListener(notificationListener);
  68. // //本地通知回调
  69. // var localNotificationListener = result => {
  70. // console.log("localNotificationListener:" + JSON.stringify(result))
  71. // };
  72. // JPush.addLocalNotificationListener(localNotificationListener);
  73. // //自定义消息回调
  74. // var customMessageListener = result => {
  75. // console.log("customMessageListener:" + JSON.stringify(result))
  76. // };
  77. // JPush.addCustomMessageListener(customMessageListener);
  78. // //应用内消息回调
  79. // JPush.pageEnterTo("HomePage") // 进入首页,当页面退出时请调用 JPush.pageLeave('HomePage')
  80. // var inappMessageListener = result => {
  81. // console.log("inappMessageListener:" + JSON.stringify(result))
  82. // alert(JSON.stringify(result))
  83. // };
  84. // JPush.addInappMessageListener(inappMessageListener);
  85. // //tag alias事件回调
  86. // var tagAliasListener = result => {
  87. // console.log("tagAliasListener:" + JSON.stringify(result))
  88. // };
  89. // JPush.addTagAliasListener(tagAliasListener);
  90. // //手机号码事件回调
  91. // var mobileNumberListener = result => {
  92. // console.log("mobileNumberListener:" + JSON.stringify(result))
  93. // };
  94. // JPush.addMobileNumberListener(mobileNumberListener);
  95. }
  96. return <Provider store={store}>
  97. {process.env.TARO_ENV == 'rn' && <StatusBar barStyle='light-content' />}
  98. {children}
  99. </Provider>
  100. }
  101. // class App extends Component<PropsWithChildren> {
  102. // componentDidMount () {}
  103. // componentDidShow () {}
  104. // componentDidHide () {}
  105. // // this.props.children 是将要会渲染的页面
  106. // render () {
  107. // return this.props.children
  108. // }
  109. // }
  110. export default App