|
|
@@ -1,11 +1,12 @@
|
|
|
import { Component, PropsWithChildren } from 'react'
|
|
|
import './app.scss'
|
|
|
import '@/context/locales/index'
|
|
|
-import { Provider } from 'react-redux'
|
|
|
+import { Provider, useDispatch } 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 { getInfoSuccess } from './store/user'
|
|
|
// import { StatusBar } from 'react-native'
|
|
|
// import jgPush from './utils/push.rn'
|
|
|
|
|
|
@@ -22,10 +23,15 @@ if (process.env.TARO_ENV == 'rn') {
|
|
|
|
|
|
|
|
|
const App: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
- if (process.env.TARO_ENV=='rn'){
|
|
|
+
|
|
|
+ // const dispatch = useDispatch();
|
|
|
+
|
|
|
+
|
|
|
+ if (process.env.TARO_ENV == 'rn') {
|
|
|
// alert(Intl.DateTimeFormat().resolvedOptions().timeZone)
|
|
|
}
|
|
|
if (process.env.TARO_ENV == 'weapp') {
|
|
|
+ loadWXCache()
|
|
|
global.isDebug = Taro.getStorageSync('isDebug')
|
|
|
|
|
|
const updateManager = Taro.getUpdateManager()
|
|
|
@@ -53,6 +59,7 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
}
|
|
|
else {
|
|
|
//关闭其中某些yellow警告
|
|
|
+ loadRNCache()
|
|
|
LogBox.ignoreLogs(['Warning: ...']); // Ignore log notification by message
|
|
|
LogBox.ignoreAllLogs();//Ignore all log notifications
|
|
|
|
|
|
@@ -105,6 +112,47 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ function loadWXCache() {
|
|
|
+ // var showDayRing = Taro.getStorageSync('showDayRing') || false;
|
|
|
+ // var showNightRing = Taro.getStorageSync('showNightRing') || false;
|
|
|
+ // dispatch(showDay(showDayRing))
|
|
|
+ // dispatch(showNight(showNightRing))
|
|
|
+ // var gps = Taro.getStorageSync('gps')
|
|
|
+ // if (gps) {
|
|
|
+ // global.locationDetail = JSON.parse(gps)
|
|
|
+ // }
|
|
|
+ var userData = Taro.getStorageSync('userData')
|
|
|
+ if (userData) {
|
|
|
+ global.token = JSON.parse(userData).token
|
|
|
+ // dispatch(getInfoSuccess(JSON.parse(userData)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async function loadRNCache() {
|
|
|
+ // var showDayRing = await getStorage('showDayRing') || false;
|
|
|
+ // var showNightRing = await getStorage('showNightRing') || false;
|
|
|
+ // dispatch(showDay(showDayRing))
|
|
|
+ // dispatch(showNight(showNightRing))
|
|
|
+ // var gps = await getStorage('gps')
|
|
|
+ // if (gps) {
|
|
|
+ // global.locationDetail = JSON.parse(gps)
|
|
|
+ // }
|
|
|
+ var userData = await getStorage('userData')
|
|
|
+ if (userData) {
|
|
|
+ global.token = JSON.parse(userData).token
|
|
|
+ // dispatch(getInfoSuccess(JSON.parse(userData)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async function getStorage(key: string) {
|
|
|
+ try {
|
|
|
+ const res = await Taro.getStorage({ key });
|
|
|
+ return res.data;
|
|
|
+ } catch {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return <Provider store={store}>
|
|
|
{process.env.TARO_ENV == 'rn' && <StatusBar barStyle='light-content' />}
|
|
|
{children}
|