소스 검색

add some desc

leon 1 년 전
부모
커밋
2c807ac312

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 0
ios/main.jsbundle


+ 2 - 2
src/context/locales/zh.js

@@ -130,7 +130,7 @@ export default {
             multi_timezones: '跨多时区',
             different_timezone: '其他时区',
             multi_tz_desc: '打卡事件涉及到多个时区。',
-            diff_tz_desc: '打卡事件发生在 {{location}} 时区, 比您当前设备时区 {{device_location}} 靠{{offset}}',
+            diff_tz_desc: '事件发生在 {{location}} 时区, 比您当前设备时区 {{device_location}} 靠{{offset}}',
             become_pro: '成为会员',
             overnight: '夜晚',
             day: '白天',
@@ -287,7 +287,7 @@ export default {
             behind_desc: '后{{time}}',
             ahead_of: '前',
             behind: '后',
-            diff_tz_desc: '上述事件发生在{{location}}时区, 比您当前设备时区{{type}}{{time}}',
+            // diff_tz_desc: '上述事件发生在{{location}}时区, 比您当前设备时区{{type}}{{time}}',
             upcoming: '接下来',
             in_real_time: '进行中',
             ended: '已结束',

+ 2 - 8
src/features/daynight/DayNightCard.tsx

@@ -12,7 +12,7 @@ import { systemLocation } from '@/services/common'
 import { setDayRingData, showDay } from '@/store/day'
 import { setNightRingData, showNight, updateMember } from '@/store/night'
 import Modal from '@/components/layout/Modal.weapp'
-import { rpxToPx } from '@/utils/tools'
+import { getTimezone, rpxToPx } from '@/utils/tools'
 import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
 import DayNightDetailPopup from './DayNightDetailPopup'
 import '@/utils/ring_card.scss';
@@ -576,13 +576,7 @@ export default function DayNightCard(props: { isNight: boolean, count: number })
     }
 
     function detailModalContent() {
-        var split = new Date().toString().split(' ');
-        var timezone = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                timezone = item;
-            }
-        })
+        var timezone = getTimezone()
         if (!authInfo || !(authInfo as any).lat) {
             return <View style={{ height: 100, display: 'flex', alignItems: 'center', justifyContent: 'center', width: rpxToPx(750) }}>
                 <Text>暂无位置信息</Text>

+ 44 - 3
src/features/daynight/DayNightDetailPopup.tsx

@@ -2,7 +2,7 @@ import { View, Text } from '@tarojs/components'
 import '@/features/trackTimeDuration/components/CircadianDetailPopup.scss'
 import { useTranslation } from 'react-i18next'
 import { useEffect, useState } from 'react'
-import { rpxToPx } from '@/utils/tools'
+import { getTimezone, getTimezoneName, rpxToPx } from '@/utils/tools'
 import { TimeFormatter } from '@/utils/time_format'
 import { useSelector } from 'react-redux'
 import { ColorType } from '@/context/themes/color'
@@ -471,6 +471,44 @@ export default function DayNightDetailPopup(props: {
         </View>
     }
 
+    function getTZLocation() {
+        var name = props.authInfo.timezone
+        if (props.authInfo.timezone_name) {
+            name = `${name} (${props.authInfo.timezone_name})`
+        }
+        return name
+
+    }
+
+    function getDeviceLocation() {
+        return `${getTimezone()} (${getTimezoneName()})`
+    }
+
+    function getTZOffset() {
+        var current1 = dayjs()
+        var current = dayjs().tz(props.authInfo.timezone_id)
+        var offset = current.date() * 24 * 60 + current.hour() * 60 + current.minute() - current1.date() * 24 * 60 - current1.hour() * 60 - current1.minute()
+
+        var hour = Math.floor(Math.abs(offset) / 60)
+        var minute = Math.abs(offset) % 60
+        var time = ''
+        if (global.language == 'en') {
+            time = `${hour} h`
+            if (minute > 0) {
+                time += ` ${minute} m`
+            }
+        }
+        else {
+            time = `${hour}小时`
+            if (minute > 0) {
+                time += `${minute}分钟`
+            }
+        }
+        return offset > 0 ? t('feature.day_night.ahead_desc', { time: time }) : t('feature.day_night.behind_desc', { time: time })
+    }
+
+
+
     function diffentTZDesc() {
         var current1 = dayjs()
         var current = dayjs().tz(props.authInfo.timezone_id)
@@ -495,9 +533,12 @@ export default function DayNightDetailPopup(props: {
                 time += `${minute}分钟`
             }
         }
-        return t('feature.day_night.diff_tz_desc', { location: props.authInfo.timezone_id, time: time, type: type })
+        return t('feature.common.diff_tz_desc', { location: getTZLocation(), device_location: getDeviceLocation(), offset: getTZOffset() })
+        // return t('feature.common.diff_tz_desc', { location: props.authInfo.timezone_id, time: time, type: type })
     }
 
+
+
     function getLocation() {
         var city = ''
         if ((props.authInfo as any).address) {
@@ -539,7 +580,7 @@ export default function DayNightDetailPopup(props: {
             showCancel: true,
             cancelText: t('feature.day_night.later'),
             confirmText: t('feature.day_night.picker_now'),
-            confirm:()=>{
+            confirm: () => {
                 props.updateLocation()
             }
         })

+ 2 - 8
src/features/trackTimeDuration/components/CircadianDetailPopup.tsx

@@ -8,7 +8,7 @@ import { bigRingRadius, getBgRing, getCommon, getDot, ringWidth } from '../hooks
 import { ColorType } from '@/context/themes/color';
 import { useTranslation } from 'react-i18next';
 import { TimeFormatter } from '@/utils/time_format';
-import { rpxToPx } from '@/utils/tools';
+import { getTimezone, rpxToPx } from '@/utils/tools';
 import { useSelector } from 'react-redux';
 import { durationDatas, durationIndex, getColor, getDurationTitle } from '../hooks/Console';
 import Modal from '@/components/layout/Modal.weapp';
@@ -69,13 +69,7 @@ export default function CircadianDetailPopup(props: { record: any, schedule?: an
 
 
     function checkTimezone() {
-        var split = new Date().toString().split(' ');
-        var currentTZ = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                currentTZ = item;
-            }
-        })
+        var currentTZ = getTimezone()
         var isDiff = false;
         var isMulti = false;
         var tempTZ = '';

+ 3 - 15
src/features/trackTimeDuration/components/RecordFastSleep.tsx

@@ -20,7 +20,7 @@ import { ColorType } from "@/context/themes/color";
 import TimelineStage from "./TimelineStage";
 import { jumpPage } from "../hooks/Common";
 import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
-import { rpxToPx } from "@/utils/tools";
+import { getTimezone, rpxToPx } from "@/utils/tools";
 import { useDispatch, useSelector } from "react-redux";
 import { setSelID } from "@/store/common";
 import CircadianDetailPopup from "./CircadianDetailPopup";
@@ -104,13 +104,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number, d
     }, [common.recordSelID])
 
     function checkTimezone() {
-        var split = new Date().toString().split(' ');
-        var currentTZ = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                currentTZ = item;
-            }
-        })
+        var currentTZ = getTimezone()
         var isDiff = false;
         var isMulti = false;
         var tempTZ = '';
@@ -434,13 +428,7 @@ const RecordFastSleep = memo((props: { data: any, type: string, index: number, d
     }
 
     function getArrowText() {
-        var split = new Date().toString().split(' ');
-        var timeZoneFormatted = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                timeZoneFormatted = item;
-            }
-        })
+        var timeZoneFormatted = getTimezone()
 
         if (multiTimeZone) {
             if (props.data.first_time_zone_id) {

+ 20 - 15
src/features/trackTimeDuration/components/TimelineFastSleep.tsx

@@ -8,7 +8,7 @@ import { useEffect, useState } from "react";
 import { useSelector } from "react-redux";
 import './TimelineFastSleep.scss'
 import dayjs from 'dayjs'
-import { rpxToPx } from "@/utils/tools";
+import { getTimezone, getTimezoneName, rpxToPx } from "@/utils/tools";
 import Taro from "@tarojs/taro";
 
 
@@ -297,26 +297,31 @@ export default function TimelineFastSleep(props: {
     }
 
     function getTZLocation() {
+        /*
+        var name = props.authInfo.timezone
+        if (props.authInfo.timezone_name) {
+            name = `${name} (${props.authInfo.timezone_name})`
+        }
+        return name
+        */
         if (props.data.fast) {
-            if (props.data.fast.real_start_time_zone_id) {
-                return `${dayjs().tz(props.data.fast.real_start_time_zone_id).format('z')} (${props.data.fast.real_start_time_zone_id})`
+            var name = props.data.fast.real_start_time_zone
+            if (props.data.fast.real_start_time_zone_name) {
+                name = `${name} (${props.data.fast.real_start_time_zone_name})`
             }
-            return props.data.fast.real_start_time_zone
+            return name
         }
         else {
-            if (props.data.sleep.real_start_time_zone_id) {
-                return `${dayjs().tz(props.data.sleep.real_start_time_zone_id).format('z')} (${props.data.sleep.real_start_time_zone_id})`
-                // return props.data.sleep.real_start_time_zone_id
+            var name = props.data.sleep.real_start_time_zone
+            if (props.data.sleep.real_start_time_zone_name) {
+                name = `${name} (${props.data.sleep.real_start_time_zone_name})`
             }
-            return props.data.sleep.real_start_time_zone
+            return name
         }
     }
 
-    function getDeviceLocation(){
-        if (Taro.getSystemInfoSync().platform == 'ios') {
-            return `${dayjs().format('z')} (${dayjs.tz.guess()})`
-        }
-        return `${dayjs().format('z')}`
+    function getDeviceLocation() {
+        return `${getTimezone()} (${getTimezoneName()})`
     }
 
     function getTZOffset() {
@@ -370,10 +375,10 @@ export default function TimelineFastSleep(props: {
             </View>
         </View>
         {
-            multTimeZone && <Text className="tz_note_desc" style={{width:rpxToPx(538)}}>{t('feature.common.multi_tz_desc')}</Text>
+            multTimeZone && <Text className="tz_note_desc" style={{ width: rpxToPx(538) }}>{t('feature.common.multi_tz_desc')}</Text>
         }
         {
-            !multTimeZone && diffTimeZone && <Text className="tz_note_desc" style={{width:rpxToPx(538)}}>{t('feature.common.diff_tz_desc', { location: getTZLocation(), offset: getTZOffset(),device_location:getDeviceLocation() })}</Text>
+            !multTimeZone && diffTimeZone && <Text className="tz_note_desc" style={{ width: rpxToPx(538) }}>{t('feature.common.diff_tz_desc', { location: getTZLocation(), offset: getTZOffset(), device_location: getDeviceLocation() })}</Text>
         }
     </View>
 }

+ 7 - 19
src/pages/clock/Clock.tsx

@@ -18,7 +18,7 @@ import { bigRingRadius, getBgRing, getCommon, getDot, getSchedule, ringWidth, sm
 import { RealRing, CurrentDot } from "@/features/trackTimeDuration/components/Rings";
 import IndexConsole from "@/features/trackTimeDuration/components/IndexConsole";
 import Modal from '@/components/layout/Modal'
-import { compareVersion, rpxToPx } from "@/utils/tools";
+import { compareVersion, getTimezone, rpxToPx } from "@/utils/tools";
 import RecordFastSleep from "@/features/trackTimeDuration/components/RecordFastSleep";
 import DayLight from "@/features/trackTimeDuration/components/DayLight";
 import { getInfo, latestLocation } from "@/services/user";
@@ -335,13 +335,7 @@ export default function Page() {
 
     function checkTimeZone() {
         setCount((prevCounter) => prevCounter + 1)
-        var split = new Date().toString().split(' ');
-        var timeZoneFormatted = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                timeZoneFormatted = item;
-            }
-        })
+        var timeZoneFormatted = getTimezone()
 
 
         Taro.getStorage({
@@ -398,20 +392,14 @@ export default function Page() {
             // var locale = NativeModules.SettingsManager.settings.AppleLocale ||
             //     NativeModules.SettingsManager.settings.AppleLanguages[0] // "fr_FR"
 
-            showAlert({
-                title: 'locale',
-                content: JSON.stringify(NativeModules.SettingsManager.settings)
-            })
+            // showAlert({
+            //     title: 'locale',
+            //     content: JSON.stringify(NativeModules.SettingsManager.settings)
+            // })
             // Android:
             // locale = NativeModules.I18nManager.localeIdentifier // "fr_FR"
         }
-        var split = new Date().toString().split(' ');
-        var timeZoneFormatted = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                timeZoneFormatted = item;
-            }
-        })
+        var timeZoneFormatted = getTimezone()
         var timeZoneId = ''
         if (Taro.getSystemInfoSync().platform == 'ios') {
             timeZoneId = dayjs.tz.guess()

+ 6 - 8
src/services/http/request.ts

@@ -5,6 +5,7 @@ import { useDispatch } from "react-redux";
 
 import dayjs from 'dayjs'
 import { APP_VERSION, WX_VERSION } from "./api";
+import { getTimezone, getTimezoneName } from "@/utils/tools";
 
 const utc = require('dayjs/plugin/utc')
 const timezone = require('dayjs/plugin/timezone')
@@ -64,22 +65,19 @@ export async function request<T>(param: RequestParam): Promise<T> {
 
         const token = global.token ? global.token : ''; //await getStorage('token')
 
-        var split = new Date().toString().split(' ');
-
-        var timeZoneFormatted = split[split.length - 2];
-        split.map(item => {
-            if (item.indexOf('GMT') != -1) {
-                timeZoneFormatted = item;
-            }
-        })
+        var timeZoneFormatted = getTimezone()
+        var timeZoneName = getTimezoneName()
         // var timeZoneLocation = Intl.DateTimeFormat().resolvedOptions().timeZone
 
         header['content-type'] = 'application/json'
         header['X-Time-Zone'] = timeZoneFormatted; //new Date().getTimezoneOffset() / 60
+        header['X-Time-Zone-Name'] = timeZoneName;
         if (Taro.getSystemInfoSync().platform == 'ios') {
             header['X-Time-Zone-Id'] = dayjs.tz.guess() ? dayjs.tz.guess() : '';
         }
 
+        
+
         header['X-Platform'] = Taro.getSystemInfoSync().platform == 'ios' ? 'IOS' : 'ANDROID'; //IOS ANDROID
         header['X-Lang'] = process.env.TARO_ENV == 'rn' ? 'en' : 'zh' //zh en
         header['X-Client-Type'] = process.env.TARO_ENV == 'rn' ? 'APP' : 'WX_APP' //WX_APP APP

+ 31 - 14
src/utils/tools.ts

@@ -62,24 +62,41 @@ export function compareVersion(v1, v2) {
     v1 = v1.split('.')
     v2 = v2.split('.')
     const len = Math.max(v1.length, v2.length)
-  
+
     while (v1.length < len) {
-      v1.push('0')
+        v1.push('0')
     }
     while (v2.length < len) {
-      v2.push('0')
+        v2.push('0')
     }
-  
+
     for (let i = 0; i < len; i++) {
-      const num1 = parseInt(v1[i])
-      const num2 = parseInt(v2[i])
-  
-      if (num1 > num2) {
-        return 1
-      } else if (num1 < num2) {
-        return -1
-      }
+        const num1 = parseInt(v1[i])
+        const num2 = parseInt(v2[i])
+
+        if (num1 > num2) {
+            return 1
+        } else if (num1 < num2) {
+            return -1
+        }
     }
-  
+
     return 0
-  }
+}
+
+export function getTimezone() {
+    var split = new Date().toString().split(' ');
+    var timeZoneFormatted = '';
+    split.map(item => {
+        if (item.indexOf('GMT') != -1) {
+            timeZoneFormatted = item;
+        }
+    })
+    return timeZoneFormatted;
+}
+
+export function getTimezoneName(){
+    var split = new Date().toString().split('(');
+    return split[1].split(')')[0];
+    
+}

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.