Leon 1 سال پیش
والد
کامیت
862a5f6b8d

+ 10 - 2
src/features/trackTimeDuration/components/WeekCalendar.tsx

@@ -34,9 +34,13 @@ const WeekCalendar = memo(() => {
     global.refrehWeekly = () => {
     global.refrehWeekly = () => {
         // getRecords()
         // getRecords()
         if (isLoading) return
         if (isLoading) return
-        pageIndex=0;
+        pageIndex = 0;
         setIsLoading(true)
         setIsLoading(true)
         var timestamp = TimeFormatter.getMondayTimestamp()
         var timestamp = TimeFormatter.getMondayTimestamp()
+        var now = new Date()
+        if (now.getDay() == 0 && now.getHours() >= 0 && now.getHours() < 12) {
+            timestamp -= 24 * 3600 * 1000 * 7
+        }
         var list: any = []
         var list: any = []
         var offset = 12 * 3600 * 1000 + pageIndex * pageSize * 24 * 3600 * 1000
         var offset = 12 * 3600 * 1000 + pageIndex * pageSize * 24 * 3600 * 1000
         for (var i = 0; i < pageSize; i++) {
         for (var i = 0; i < pageSize; i++) {
@@ -57,9 +61,13 @@ const WeekCalendar = memo(() => {
 
 
     function getRecords() {
     function getRecords() {
         if (isLoading) return
         if (isLoading) return
-        pageIndex=0;
+        pageIndex = 0;
         setIsLoading(true)
         setIsLoading(true)
         var timestamp = TimeFormatter.getMondayTimestamp()
         var timestamp = TimeFormatter.getMondayTimestamp()
+        var now = new Date()
+        if (now.getDay() == 0 && now.getHours() >= 0 && now.getHours() < 12) {
+            timestamp -= 24 * 3600 * 1000 * 7
+        }
         var list: any = []
         var list: any = []
         var offset = 12 * 3600 * 1000 + pageIndex * pageSize * 24 * 3600 * 1000
         var offset = 12 * 3600 * 1000 + pageIndex * pageSize * 24 * 3600 * 1000
         for (var i = 0; i < pageSize; i++) {
         for (var i = 0; i < pageSize; i++) {

+ 22 - 3
src/features/trackTimeDuration/components/WeekCalendarItem.tsx

@@ -10,6 +10,21 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
     const [showCurrentTime, setShowCurrentTime] = useState(false)
     const [showCurrentTime, setShowCurrentTime] = useState(false)
     const [position, setPosition] = useState({ left: 0, top: 0 })
     const [position, setPosition] = useState({ left: 0, top: 0 })
     useEffect(() => {
     useEffect(() => {
+        if (props.isCurrentWeek) {
+            if (timer)
+                clearInterval(timer)
+            if (props.isCurrentWeek) {
+                timer = setInterval(() => {
+                    getPosition()
+                }, 6000)
+                getPosition()
+            }
+            setShowCurrentTime(props.isCurrentWeek)
+        }
+        else {
+            if (timer)
+                clearInterval(timer)
+        }
         var array: any = []
         var array: any = []
         for (var i = 0; i < 7; i++) {
         for (var i = 0; i < 7; i++) {
             var start = props.data.start + 24 * 3600 * 1000 * i
             var start = props.data.start + 24 * 3600 * 1000 * i
@@ -44,18 +59,19 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
         }
         }
         setCharts(array)
         setCharts(array)
 
 
-        return ()=>{
+        return () => {
             timer && clearInterval(timer)
             timer && clearInterval(timer)
         }
         }
     }, [props.data])
     }, [props.data])
 
 
     useEffect(() => {
     useEffect(() => {
+        debugger
         if (timer)
         if (timer)
             clearInterval(timer)
             clearInterval(timer)
         if (props.isCurrentWeek) {
         if (props.isCurrentWeek) {
-            timer = setInterval(()=>{
+            timer = setInterval(() => {
                 getPosition()
                 getPosition()
-            },60000)
+            }, 60000)
             getPosition()
             getPosition()
         }
         }
         setShowCurrentTime(props.isCurrentWeek)
         setShowCurrentTime(props.isCurrentWeek)
@@ -67,6 +83,9 @@ export default function WeekCalendarItem(props: { data: any, isCurrentWeek: bool
         var index = Math.floor((now - start) / (3600 * 24 * 1000))
         var index = Math.floor((now - start) / (3600 * 24 * 1000))
         var left = (now - start) % (3600 * 24 * 1000)
         var left = (now - start) % (3600 * 24 * 1000)
         var top = left / (3600 * 24 * 1000) * 400
         var top = left / (3600 * 24 * 1000) * 400
+        if (top >=398){
+            top = 398
+        }
         setPosition({
         setPosition({
             left: rpxToPx(94 * index),
             left: rpxToPx(94 * index),
             top: rpxToPx(top)
             top: rpxToPx(top)

+ 13 - 5
src/pages/clock/Clock.tsx

@@ -103,6 +103,12 @@ export default function Page() {
     useEffect(() => {
     useEffect(() => {
         dispatch(staticResources() as any);
         dispatch(staticResources() as any);
         timer = setInterval(() => {
         timer = setInterval(() => {
+            var now = new Date()
+            if (now.getDay() == 0 && now.getHours() == 12 && now.getMinutes() == 0 && now.getSeconds() == 0) {
+                if (global.refrehWeekly) {
+                    global.refrehWeekly()
+                }
+            }
             if (global.pauseIndexTimer || pauseTimer) {
             if (global.pauseIndexTimer || pauseTimer) {
                 return
                 return
             }
             }
@@ -206,13 +212,13 @@ export default function Page() {
 
 
     usePageScroll((e) => {
     usePageScroll((e) => {
         if (e.scrollTop > 70) {
         if (e.scrollTop > 70) {
-          setShowTip(true)
+            setShowTip(true)
         }
         }
         else {
         else {
-          setShowTip(false)
+            setShowTip(false)
         }
         }
-    
-      })
+
+    })
 
 
     useDidHide(() => {
     useDidHide(() => {
         //pause timer
         //pause timer
@@ -237,7 +243,9 @@ export default function Page() {
             key: 'last_tz',
             key: 'last_tz',
             success: function (res) {
             success: function (res) {
                 if (res.data && res.data != timeZoneFormatted) {
                 if (res.data && res.data != timeZoneFormatted) {
-
+                    if (global.refrehWeekly) {
+                        global.refrehWeekly()
+                    }
                     if (global.currentStatus != 'WAIT_FOR_START') {
                     if (global.currentStatus != 'WAIT_FOR_START') {
                         Taro.showModal({
                         Taro.showModal({
                             title: t('feature.track_time_duration.change_tz_alert.title'),
                             title: t('feature.track_time_duration.change_tz_alert.title'),