Leon hai 1 ano
pai
achega
c80fb5332b

+ 16 - 16
src/features/trackSomething/components/DayNightCard.tsx

@@ -235,21 +235,21 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
         const isShow = await getStorage(props.isNight ? 'showNightRing' : 'showDayRing') || false
         setExpand(isShow)
 
-        const gpsInfo = await getStorage('gps') || null
-        if (gpsInfo) {
-            var data = JSON.parse(gpsInfo)
-            setAuthInfo(data)
-            setSunriseTime((data as any).daylights[0].sunrise)
-            setSunriseTmrTime((data as any).daylights[1].sunrise)
-            setSunsetTime((data as any).daylights[0].sunset)
-            dispatch(updateMember({ isMember: user.test_user, gpsInfo: data }))
-        }
-        else {
-            setSunriseTime('06:00')
-            setSunriseTmrTime('06:00')
-            setSunsetTime('18:00')
-            setAuthInfo(null)
-        }
+        // const gpsInfo = await getStorage('gps') || null
+        // if (gpsInfo) {
+        //     var data = JSON.parse(gpsInfo)
+        //     setAuthInfo(data)
+        //     setSunriseTime((data as any).daylights[0].sunrise)
+        //     setSunriseTmrTime((data as any).daylights[1].sunrise)
+        //     setSunsetTime((data as any).daylights[0].sunset)
+        //     dispatch(updateMember({ isMember: user.test_user, gpsInfo: data }))
+        // }
+        // else {
+        //     setSunriseTime('06:00')
+        //     setSunriseTmrTime('06:00')
+        //     setSunsetTime('18:00')
+        //     setAuthInfo(null)
+        // }
         if (props.isNight) {
             global.showNightRing = isShow
             global.refreshIndex()
@@ -319,7 +319,7 @@ export default function DayNightCard(props: { isNight: boolean, switchChanged: F
             success: function (res) {
                 console.log(res)
                 var today = new Date()
-                var yesterday = new Date(today.getTime() - 24 * 3600 * 1000)
+                var yesterday = new Date(today.getTime())
                 var tomorrow = new Date(today.getTime() + 24 * 3600 * 1000 * 3)
                 var strYesterday = `${yesterday.getFullYear()}-${TimeFormatter.padZero(yesterday.getMonth() + 1)}-${TimeFormatter.padZero(yesterday.getDate())}`
                 var strTomorrow = `${tomorrow.getFullYear()}-${TimeFormatter.padZero(tomorrow.getMonth() + 1)}-${TimeFormatter.padZero(tomorrow.getDate())}`

+ 6 - 3
src/features/trackTimeDuration/components/IndexItem.tsx

@@ -237,14 +237,17 @@ export default function Component(props: { type: string, data: any, time: any, s
         if (duration2 < 0) {
             duration2 += 24 * 60
         }
-        const realRing: RealRing = {
+        let realRing: RealRing = {
             color: ColorType.night,
             startArc: (sunSet * 60) / (24 * 3600) * 2 * Math.PI - Math.PI / 2.0,
             durationArc: (duration2 * 60) / (24 * 3600) * 2 * Math.PI
         }
 
-        if (new Date().getDate()){
-
+        if (dayNight.nightRingDate){
+            if (new Date(dayNight.nightRingDate).getDate()== new Date().getDate() && new Date().getHours()<12){
+                
+                realRing = null;
+            }
         }
 
 

+ 4 - 0
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -43,6 +43,10 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
             })
         }
         setCharts(array)
+
+        return ()=>{
+            timer && clearInterval(timer)
+        }
     }, [])
 
     useEffect(() => {

+ 1 - 0
src/features/workout/Workout.tsx

@@ -104,6 +104,7 @@ export default function Component(props: any) {
                 setAllowRun(res.data ? res.data : false)
             }
         });
+        return timer && clearInterval(timer)
     }, [])
 
     //页面渲染完成后执行一次授权检查

+ 2 - 0
src/features/workout/WorkoutTimer.tsx

@@ -61,6 +61,8 @@ export default function Component() {
             setRecords(records)
         }
         countdownText()
+
+        return timer && clearInterval(timer)
         // console.log(count)
         // console.log(record)
     }, [count])

+ 3 - 1
src/pages/clock/Index.tsx

@@ -39,6 +39,7 @@ import StageSelector from "@/features/trackTimeDuration/components/StageSelector
 let GradientText
 let useNavigation;
 let isPause = false;
+let timer
 
 if (process.env.TARO_ENV == 'rn') {
     GradientText = require('@/components/basic/GradientText').default
@@ -90,13 +91,14 @@ export default function Page() {
 
     useEffect(() => {
         global.showNightRing = false;
-        setInterval(() => {
+        timer = setInterval(() => {
             if (isPause) {
                 return
             }
             setCount((prevCounter) => prevCounter + 1)
                 
         }, 1000)
+        return timer && clearInterval(timer)
     }, [])
 
     useEffect(() => {

+ 3 - 1
src/pages/explore/Index.tsx

@@ -7,14 +7,16 @@ import TitleView from "@/features/trackTimeDuration/components/TitleView";
 import Discovery from "@/features/trackTimeDuration/components/Discovery";
 import { useEffect, useState } from "react";
 
+let timer
 export default function Explore() {
     const { t } = useTranslation()
     const [count, setCount] = useState(0)
 
     useEffect(() => {
-        setInterval(() => {
+        timer = setInterval(() => {
             setCount((prevCounter) => prevCounter + 1)
         }, 1000)
+        return timer && clearInterval(timer)
     }, [])
 
     function detail() {

+ 2 - 2
src/services/common.tsx

@@ -1,5 +1,5 @@
 import { setResources, setConfigs } from "@/store/common";
-import { API_CONFIGS, API_DEL_SESSION, API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_SYSTEM_LOCATION, API_UPLOAD_SESSION } from "./http/api";
+import { API_CONFIGS, API_DEL_SESSION, API_GLOBAL_CONFIGS, API_STATIC_RESOURCES, API_SYSTEM_LOCATION, API_UPLOAD_SESSION, API_USER_LOCATION } from "./http/api";
 import { request } from "./http/request";
 import Taro from "@tarojs/taro";
 
@@ -48,7 +48,7 @@ export const uploadSessionKey = (params) => {
 export const systemLocation = (params) => {
     return new Promise((resolve, reject) => {
         request({
-            url: API_SYSTEM_LOCATION, method: 'GET', data: {
+            url: API_USER_LOCATION, method: 'GET', data: {
                 ...params
             }
         }).then(res => {

+ 0 - 1
src/services/http/api.js

@@ -24,7 +24,6 @@ export const API_CHECK_UNIQUE = `${baseUrl}/api/user/check-unique`
 export const API_UPLOAD_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 export const API_DEL_SESSION = `${baseUrl}/api/thirdparty/wx/session`
 export const API_USER_PERMS = `${baseUrl}/api/user/perms`
-export const API_SYSTEM_LOCATION = `${baseUrl}/api/system/location`
 export const API_USER_LOCATION = `${baseUrl}/api/user/location`
 
 //track time duration