|
@@ -13,7 +13,10 @@ import Taro from "@tarojs/taro";
|
|
|
import { useTranslation } from "react-i18next";
|
|
import { useTranslation } from "react-i18next";
|
|
|
import 'dayjs/locale/zh-cn';
|
|
import 'dayjs/locale/zh-cn';
|
|
|
import 'dayjs/locale/en';
|
|
import 'dayjs/locale/en';
|
|
|
|
|
+
|
|
|
import { getTimezone, getTimezoneName } from "@/utils/tools";
|
|
import { getTimezone, getTimezoneName } from "@/utils/tools";
|
|
|
|
|
+
|
|
|
|
|
+import { AppState } from "react-native";
|
|
|
// import 'moment/locale/en';
|
|
// import 'moment/locale/en';
|
|
|
|
|
|
|
|
|
|
|
|
@@ -41,12 +44,47 @@ export default function IndexTimePage() {
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
getLanguage();
|
|
getLanguage();
|
|
|
- login()
|
|
|
|
|
|
|
+ AppState.addEventListener('change', handleAppStateChange);
|
|
|
|
|
+ // login()
|
|
|
setInterval(() => {
|
|
setInterval(() => {
|
|
|
setCount(t => t + 1)
|
|
setCount(t => t + 1)
|
|
|
|
|
+ const now = new Date()
|
|
|
|
|
+ const seconds = now.getHours()*3600+now.getMinutes()*60+now.getSeconds()
|
|
|
|
|
+ if (current && current.time && current.time.timezone.use_dst){
|
|
|
|
|
+ if (current.time_changes && current.time_changes.length>1){
|
|
|
|
|
+ const date = new Date(current.time_changes[1].timestamp)
|
|
|
|
|
+ const seconds2 = date.getHours()*3600+date.getMinutes()*60+date.getSeconds()
|
|
|
|
|
+ if (seconds == seconds2){
|
|
|
|
|
+ refresh()
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}, 1000)
|
|
}, 1000)
|
|
|
}, [])
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
+ const handleAppStateChange = (nextAppState) => {
|
|
|
|
|
+ console.log(nextAppState)
|
|
|
|
|
+ if (nextAppState != 'active') {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ if (nextAppState == 'active') {
|
|
|
|
|
+ console.log('active')
|
|
|
|
|
+ refresh()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ function refresh() {
|
|
|
|
|
+ if (current) {
|
|
|
|
|
+ chooseLocation({
|
|
|
|
|
+ lat: current.geo.lat,
|
|
|
|
|
+ lng: current.geo.lng
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function getLanguage() {
|
|
async function getLanguage() {
|
|
|
var strLocation = await getStorage('lastLocation')
|
|
var strLocation = await getStorage('lastLocation')
|
|
|
if (strLocation) {
|
|
if (strLocation) {
|