Leon 2 år sedan
förälder
incheckning
1ab36d8c91

+ 6 - 2
src/components/input/LimitPickers.tsx

@@ -155,12 +155,16 @@ const Component = forwardRef((props: {
     }
 
     function cancel(e) {
-        e.stopPropagation();
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         props.onCancel()
     }
 
     function confirm(e) {
-        e.stopPropagation();
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         if (isDisableConfirm){
             return;
         }

+ 9 - 4
src/components/input/PickerViews.tsx

@@ -8,7 +8,7 @@ const Component = forwardRef((props: {
     value: any, onChange: Function, items: any, height?: number, showBtns?: boolean, onCancel?: Function,
     themeColor?: string, title?: string
 }, ref) => {
-    const {t} = useTranslation()
+    const { t } = useTranslation()
     const [v, setV] = useState([0])
     var color = props.themeColor ? props.themeColor : '#ff0000'
     var alpha = alphaToHex(0.4)
@@ -35,8 +35,9 @@ const Component = forwardRef((props: {
     }
 
     function confirm(e) {
-        e.stopPropagation();
-        // return v;
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         props.onChange(v)
     }
 
@@ -67,7 +68,11 @@ const Component = forwardRef((props: {
 
         </PickerView >
         <View className='modal_operate'>
-            <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={(e)=>{e.stopPropagation();props.onCancel!()}}>
+            <View className='modal_btn' style={{ backgroundColor: color + alpha }} onClick={(e) => {
+                if (process.env.TARO_ENV == 'weapp') {
+                    e.stopPropagation()
+                }; props.onCancel!()
+            }}>
                 <Text className='modal_cancel_text' style={{ color: color }}>{t('feature.common.picker_cancel_btn')}</Text>
             </View>
             <View className='btn_space' />

+ 6 - 2
src/components/input/Stepper.tsx

@@ -22,7 +22,9 @@ export default function Component(props: { child: any, minus: Function, plus: Fu
 
 
     function tapMinus(e) {
-        e.stopPropagation()
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         if (props.disableMinus) {
             Taro.showToast({
                 icon: 'none',
@@ -34,7 +36,9 @@ export default function Component(props: { child: any, minus: Function, plus: Fu
     }
 
     function tapPlus(e) {
-        e.stopPropagation()
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         if (props.disablePlus){
             Taro.showToast({
                 icon: 'none',

+ 5 - 1
src/components/input/Switch.tsx

@@ -9,7 +9,11 @@ export default function Component(props: { isOn: boolean, onClick: Function }) {
         return n * rate;
     }
     if (process.env.TARO_ENV == 'weapp') {
-        return <View className="switch1" style={{ backgroundColor: global.isDebug ? 'blue' : 'transparent' }} onClick={(e) => { e.stopPropagation(); props.onClick() }}>
+        return <View className="switch1" style={{ backgroundColor: global.isDebug ? 'blue' : 'transparent' }} onClick={(e) => {
+            if (process.env.TARO_ENV == 'weapp') {
+                e.stopPropagation()
+            }; props.onClick()
+        }}>
 
             {
                 props.isOn ? <Image src={require('@/assets/images/bell.png')} style={{ height: rpxToPx(56), width: rpxToPx(56) }} /> :

+ 17 - 7
src/components/layout/Modal.tsx

@@ -16,13 +16,15 @@ export default function Modal(props: {
 
     //阻止中间内容点击事件穿透
     function click(e) {
-        e.stopPropagation();
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         Taro.vibrateShort({
-            type:'medium'
+            type: 'medium'
         })
     }
 
-    function onClick(){
+    function onClick() {
         // Taro.vibrateShort({
         //     type:'medium'
         // })
@@ -30,7 +32,11 @@ export default function Modal(props: {
 
     switch (props.modalType) {
         case ModalType.center:
-            return <View className='modal modal_center_container' catchMove onClick={(e) => {e.stopPropagation();props.dismiss()}}>
+            return <View className='modal modal_center_container' catchMove onClick={(e) => {
+                if (process.env.TARO_ENV == 'weapp') {
+                    e.stopPropagation()
+                }; props.dismiss()
+            }}>
                 <View className='center_modal_detail'>
                     <Box><View onClick={click}>
                         {
@@ -42,15 +48,19 @@ export default function Modal(props: {
             </View>
     }
 
-    
+
     return <View className='modal' catchMove >
 
-        <View style={{ flex: 1,width:375,flexShrink:0 }} onClick={(e) => {e.stopPropagation();props.dismiss()}}>
+        <View style={{ flex: 1, width: 375, flexShrink: 0 }} onClick={(e) => {
+            if (process.env.TARO_ENV == 'weapp') {
+                e.stopPropagation()
+            }; props.dismiss()
+        }}>
             {
                 props.testInfo ? props.testInfo : null
             }
         </View>
-        <View className='modal_bottom_content'  onClick={onClick}>
+        <View className='modal_bottom_content' onClick={onClick}>
             {/* <Text className='modal_title' style={{ color: color }}>{props.title ? props.title : '测试标题 '}</Text> */}
             {
                 props.children

+ 10 - 2
src/components/navigation/Segment.tsx

@@ -16,11 +16,19 @@ export default function Component(props: {
     }
 
     return <View className='segment'>
-        <View className={current == 0 ? 'segment_item segment_item_sel' : 'segment_item'} onClick={(e) => {e.stopPropagation(); selItem(0) }}>
+        <View className={current == 0 ? 'segment_item segment_item_sel' : 'segment_item'} onClick={(e) => {
+            if (process.env.TARO_ENV == 'weapp') {
+                e.stopPropagation()
+            }; selItem(0)
+        }}>
             <Text className={current == 0 ? 'segment_text_sel' : 'segment_text'}>{props.titles[0]}</Text>
         </View>
         <View style={{ width: 16 }} />
-        <View className={current == 1 ? 'segment_item segment_right segment_item_sel' : 'segment_item segment_right'} onClick={(e) => {e.stopPropagation(); selItem(1) }}>
+        <View className={current == 1 ? 'segment_item segment_right segment_item_sel' : 'segment_item segment_right'} onClick={(e) => {
+            if (process.env.TARO_ENV == 'weapp') {
+                e.stopPropagation()
+            }; selItem(1)
+        }}>
             <Text className={current == 1 ? 'segment_text_sel' : 'segment_text'}>{props.titles[1]}</Text>
         </View>
     </View>

+ 2 - 3
src/features/auth/components/CreateAccount.tsx

@@ -9,6 +9,7 @@ import { useState } from "react";
 import { useTranslation } from "react-i18next";
 import check from '@/assets/svg/check.svg'
 import './Auth.scss'
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 export default function Component(props:{login:()=>void}) {
   const { t } = useTranslation()
@@ -38,9 +39,7 @@ export default function Component(props:{login:()=>void}) {
     global.username = name
     global.email = email
     setTimeout(() => {
-      Taro.navigateTo({
-        url: `/pages/Auth?type=createPassword&name=${name}&email=${email}`
-      })
+      jumpPage(`/pages/Auth?type=createPassword&name=${name}&email=${email}`)
     }, 1000)
 
     // setTimeout(() => {

+ 3 - 1
src/features/common/RecordItem.tsx

@@ -10,7 +10,9 @@ export default function Component(props: { children: React.ReactNode, onClick?:
     const { t } = useTranslation()
     function click(e) {
         if (props.onClick) {
-            e.stopPropagation()
+            if (process.env.TARO_ENV == 'weapp') {
+                e.stopPropagation()
+            }
             props.onClick();
         }
         else {

+ 4 - 16
src/features/trackSomething/components/Activity.tsx

@@ -14,6 +14,7 @@ import { ResultType, checkFail, checkRetry, checkStart, checkSuccess, resetStatu
 import RequestType, { thirdPartRequest } from "@/services/thirdPartRequest";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useTranslation } from "react-i18next";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 // import { useNavigation } from "@react-navigation/native";
 
 let useNavigation;
@@ -145,16 +146,7 @@ export default function Component(props: any) {
             }
         }
         else {
-            if (process.env.TARO_ENV == 'weapp') {
-                Taro.navigateTo({
-                    url: '/pages/account/ChooseAuth'
-                })
-            }
-            else {
-                // const navigation = useNavigation()
-                navigation.navigate('ChooseAuth')
-            }
-
+            jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
         }
     }
 
@@ -282,14 +274,10 @@ export default function Component(props: any) {
             if (!allowRun) {
                 return;
             }
-            Taro.navigateTo({
-                url: '/pages/common/RecordsHistory?type=activity&refreshList=getCards&title=' + item.name + '&themeColor=' + item.theme_color
-            })
+            jumpPage('/pages/common/RecordsHistory?type=activity&refreshList=getCards&title=' + item.name + '&themeColor=' + item.theme_color)
         }
         else {
-            Taro.navigateTo({
-                url: '/pages/account/ChooseAuth'
-            })
+            jumpPage('/pages/account/ChooseAuth')
         }
 
     }

+ 8 - 10
src/features/trackSomething/components/Metric.tsx

@@ -14,6 +14,7 @@ import { alphaToHex } from "@/utils/tools";
 import Layout from "@/components/layout/layout";
 import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useTranslation } from "react-i18next";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 let useNavigation;
 if (process.env.TARO_ENV == 'rn') {
@@ -43,7 +44,10 @@ export default function Component(props: any) {
     const limitPickerRef = useRef<any>(null);
     const [count, setCount] = useState(0)
 
-
+    let navigation;
+    if (useNavigation){
+        navigation = useNavigation()
+    }
 
 
     //未登录<->已登录 状态切换时,执行一次授权检查
@@ -106,14 +110,10 @@ export default function Component(props: any) {
             if (!item.latest_record) {
                 return
             }
-            Taro.navigateTo({
-                url: '/pages/common/RecordsHistory?type=metric&refreshList=getCards&code=' + item.code + `&title=${item.name}` + '&themeColor=' + item.theme_color
-            })
+            jumpPage('/pages/common/RecordsHistory?type=metric&refreshList=getCards&code=' + item.code + `&title=${item.name}` + '&themeColor=' + item.theme_color)
         }
         else {
-            Taro.navigateTo({
-                url: '/pages/account/ChooseAuth'
-            })
+            jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
         }
     }
 
@@ -128,9 +128,7 @@ export default function Component(props: any) {
             openModal()
         }
         else {
-            Taro.navigateTo({
-                url: '/pages/account/ChooseAuth'
-            })
+            jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
         }
     }
 

+ 2 - 3
src/features/trackTimeDuration/components/ChooseScenario.tsx

@@ -19,6 +19,7 @@ import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import Layout from "@/components/layout/layout";
 import { ColorType } from "@/context/themes/color";
 import TitleView from "./TitleView";
+import { jumpPage } from "../hooks/Common";
 
 
 export default function Component() {
@@ -79,9 +80,7 @@ export default function Component() {
                     dispatch(setStep(isFastFirst ? 'fast' : 'sleep'))
                 }
         }
-        Taro.navigateTo({
-            url: '/pages/clock/SetSchedule'
-        })
+        jumpPage('/pages/clock/SetSchedule')
     }
 
     function footerContent() {

+ 15 - 4
src/features/trackTimeDuration/components/Console.tsx

@@ -17,6 +17,12 @@ import { ConsoleType, changeConsoleStatus } from "@/store/console";
 import { updateScenario } from "@/store/time";
 import { useTranslation } from "react-i18next";
 import { ColorType } from "@/context/themes/color";
+import { jumpPage } from "../hooks/Common";
+
+let useNavigation;
+if (process.env.TARO_ENV=='rn'){
+    useNavigation = require("@react-navigation/native").useNavigation
+}
 
 export default function Component(props: { isNextStep?: boolean }) {
     const scenario = useSelector((state: any) => state.scenario);
@@ -35,6 +41,11 @@ export default function Component(props: { isNextStep?: boolean }) {
     const { t } = useTranslation()
     const dispatch = useDispatch();
 
+    let navigation;
+    if (useNavigation){
+        navigation = useNavigation()
+    }
+
     useEffect(() => {
         getStateDetail();
     }, [time.fast, time.sleep, time.status, time.scenario]);
@@ -307,9 +318,7 @@ export default function Component(props: { isNextStep?: boolean }) {
     }
 
     function login() {
-        Taro.navigateTo({
-            url: '/pages/account/ChooseAuth'
-        })
+        jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
     }
 
     function durationFormate() {
@@ -321,7 +330,9 @@ export default function Component(props: { isNextStep?: boolean }) {
     }
 
     function showDurationPicker(e) {
-        e.stopPropagation()
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         var node = <Modal children={durationPickerContent()} dismiss={() => global.showClockModal2(false, null)} confirm={() => {
             var picker = durationPickerRef.current;
             durationChange((picker as any).getConfirmData());

+ 15 - 4
src/features/trackTimeDuration/components/Console_backup.tsx

@@ -17,6 +17,12 @@ import { ConsoleType, changeConsoleStatus } from "@/store/console";
 import { updateScenario } from "@/store/time";
 import { useTranslation } from "react-i18next";
 import { ColorType } from "@/context/themes/color";
+import { jumpPage } from "../hooks/Common";
+
+let useNavigation;
+if (process.env.TARO_ENV=='rn'){
+    useNavigation = require("@react-navigation/native").useNavigation
+}
 
 export default function Component(props: { isNextStep?: boolean }) {
     const scenario = useSelector((state: any) => state.scenario);
@@ -34,6 +40,11 @@ export default function Component(props: { isNextStep?: boolean }) {
     const { t } = useTranslation()
     const dispatch = useDispatch();
 
+    let navigation;
+    if (useNavigation){
+        navigation = useNavigation()
+    }
+
     useEffect(() => {
         getStateDetail();
     }, [time.fast, time.sleep, time.status, time.scenario]);
@@ -328,9 +339,7 @@ export default function Component(props: { isNextStep?: boolean }) {
     }
 
     function login() {
-        Taro.navigateTo({
-            url: '/pages/account/ChooseAuth'
-        })
+        jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
     }
 
     function durationFormate() {
@@ -342,7 +351,9 @@ export default function Component(props: { isNextStep?: boolean }) {
     }
 
     function showDurationPicker(e) {
-        e.stopPropagation()
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         var node = <Modal children={durationPickerContent()} dismiss={() => global.showClockModal2(false, null)} confirm={() => {
             var picker = durationPickerRef.current;
             durationChange((picker as any).getConfirmData());

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

@@ -18,6 +18,7 @@ import CenterContentTitleModal from "@/features/common/CenterContentTitleModal";
 import { useTranslation } from "react-i18next";
 import { ColorType } from "@/context/themes/color";
 import TimelineStage from "./TimelineStage";
+import { jumpPage } from "../hooks/Common";
 
 export default function RecordFastSleep(props: { data: any, type: string, delSuccess?: Function }) {
     const [showDetailModal, setShowDetailModal] = useState(false)
@@ -28,9 +29,7 @@ export default function RecordFastSleep(props: { data: any, type: string, delSuc
     function header() {
         if (props.type == 'latest') {
             return <Header title={t('feature.track_time_duration.record_fast_sleep.header.latest_record')} action={() => {
-                Taro.navigateTo({
-                    url: '/pages/common/RecordsHistory?type=time&title=time'
-                })
+                jumpPage('/pages/common/RecordsHistory?type=time&title=time')
             }} />
         }
         return null

+ 10 - 30
src/features/trackTimeDuration/components/Schedule.tsx

@@ -17,7 +17,7 @@ import Modal from "@/components/layout/Modal";
 import Stage from "./Stage";
 import CenterContentTitleModal from "@/features/common/CenterContentTitleModal";
 import { ColorType } from "@/context/themes/color";
-import { getThemeColor } from "../hooks/Common";
+import { getThemeColor, jumpPage } from "../hooks/Common";
 import TableCell from "@/components/layout/TableCell";
 import TimelineStage from "./TimelineStage";
 
@@ -32,14 +32,14 @@ export default function Component(props: { type?: string, data?: any, delSuccess
 
     function all() {
         if (props.type == 'latest') {
-            Taro.navigateTo({
-                url: '/pages/common/RecordsHistory?type=time&title=Time'
-            })
+            jumpPage('/pages/common/RecordsHistory?type=time&title=Time')
         }
     }
 
     function showStage(e) {
-        e.stopPropagation()
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         setShowModal(true)
     }
 
@@ -64,9 +64,7 @@ export default function Component(props: { type?: string, data?: any, delSuccess
             success(result) {
                 if (result.confirm) {
                     global.forceRefreshWXPub = true
-                    Taro.navigateTo({
-                        url: '/pages/common/H5?title=' + title + '&url=' + resource[0].url,
-                    })
+                    jumpPage('/pages/common/H5?title=' + title + '&url=' + resource[0].url)
                 }
             },
         })
@@ -109,29 +107,13 @@ export default function Component(props: { type?: string, data?: any, delSuccess
                     <Switch isOn={permission.wxPubFollow} onClick={() => followWxPub()} />
                 </View>
             }
-            {/* {
-                permission.wxPubFollow && props.data.status == 'WAIT_FOR_START' && <Buttons disabled={props.data.status != 'WAIT_FOR_START'}
-                    className={props.data.scenario == 'FAST_SLEEP' ? 'mixed' : ''}
-                    btnStyle={btnStyle} type={ButtonType.text} title="调整日程" onClick={() => {
-                        if (props.data.name == 'FAST_SLEEP') {
-                            dispatch(setStep('fast'))
-                        }
-                        else if (props.data.name == 'SLEEP') {
-                            dispatch(setStep('sleep'))
-                        }
-                        else {
-                            dispatch(setStep('fast'))
-                        }
-                        Taro.navigateTo({
-                            url: '/pages/clock/SetSchedule'
-                        })
-                    }} />
-            } */}
         </View>
     }
 
     function tapSchedule(e) {
-        e.stopPropagation();
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
 
         if (permission.wxPubFollow && props.data.status == 'WAIT_FOR_START') {
             Taro.showActionSheet({
@@ -149,9 +131,7 @@ export default function Component(props: { type?: string, data?: any, delSuccess
                             else {
                                 dispatch(setStep('fast'))
                             }
-                            Taro.navigateTo({
-                                url: '/pages/clock/SetSchedule'
-                            })
+                            jumpPage('/pages/clock/SetSchedule')
                             break;
                         case 1:
 

+ 2 - 3
src/features/trackTimeDuration/components/SetSchedule.tsx

@@ -19,6 +19,7 @@ import { NaviBarTitleShowType, TemplateType } from "@/utils/types";
 import { useTranslation } from "react-i18next";
 import { ColorType } from "@/context/themes/color";
 import TitleView from "./TitleView";
+import { jumpPage } from "../hooks/Common";
 
 export default function Component() {
   const isFastFirst = true;
@@ -136,9 +137,7 @@ export default function Component() {
 
         saveTempCache(startTime, endTime)
 
-        Taro.navigateTo({
-          url: '/pages/clock/SetSchedule'
-        })
+        jumpPage('/pages/clock/SetSchedule')
       }
       else {
         commit()

+ 2 - 3
src/features/trackTimeDuration/components/TimelineStage.tsx

@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
 import Switch from '@/components/input/Switch';
 import { useSelector } from 'react-redux';
 import Taro from '@tarojs/taro';
+import { jumpPage } from '../hooks/Common';
 
 
 export default function Component(props: { data: any, title?: string, subTitle?: string, isSchedule?: boolean }) {
@@ -37,9 +38,7 @@ export default function Component(props: { data: any, title?: string, subTitle?:
             success(result) {
                 if (result.confirm) {
                     global.forceRefreshWXPub = true
-                    Taro.navigateTo({
-                        url: '/pages/common/H5?title=' + title + '&url=' + resource[0].url,
-                    })
+                    jumpPage('/pages/common/H5?title=' + title + '&url=' + resource[0].url)
                 }
             },
         })

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

@@ -4,6 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
 import Taro from '@tarojs/taro';
 import { setStep } from '@/store/scenario';
 import { useTranslation } from 'react-i18next';
+import { jumpPage } from '../hooks/Common';
 
 export default function Component(props: {
     children?: any,
@@ -45,9 +46,7 @@ export default function Component(props: {
                     else {
                         dispatch(setStep('fast'))
                     }
-                    Taro.navigateTo({
-                        url: '/pages/clock/SetSchedule'
-                    })
+                    jumpPage('/pages/clock/SetSchedule')
                     break;
                 case 0:
                     if (time.status != 'WAIT_FOR_START') {
@@ -57,9 +56,7 @@ export default function Component(props: {
                         })
                         return;
                     }
-                    Taro.navigateTo({
-                        url: '/pages/clock/ChooseScenario'
-                    })
+                    jumpPage('/pages/clock/ChooseScenario')
                     break;
             }
         })

+ 16 - 4
src/features/trackTimeDuration/hooks/Common.tsx

@@ -1,16 +1,28 @@
 import { ColorType } from "@/context/themes/color"
+import Taro from "@tarojs/taro"
 
 export const getThemeColor = (time: any) => {
     if (time.scenario == 'FAST') {
-        return global.fastColor?global.fastColor:ColorType.fast
+        return global.fastColor ? global.fastColor : ColorType.fast
     }
     else if (time.scenario == 'SLEEP') {
-        return global.sleepColor?global.sleepColor:ColorType.sleep
+        return global.sleepColor ? global.sleepColor : ColorType.sleep
     }
     else {
         if (time.status == 'WAIT_FOR_START' || time.status == 'ONGOING3') {
-            return global.fastColor?global.fastColor:ColorType.fast
+            return global.fastColor ? global.fastColor : ColorType.fast
         }
-        return global.sleepColor?global.sleepColor:ColorType.sleep
+        return global.sleepColor ? global.sleepColor : ColorType.sleep
+    }
+}
+
+export const jumpPage = (url?: string, pageName?: string, navigation?: any) => {
+    if (process.env.TARO_ENV == 'rn') {
+        navigation.navigate(pageName);
+    }
+    else {
+        Taro.navigateTo({
+            url: url ?? ''
+        })
     }
 }

+ 2 - 3
src/pages/account/ChooseAuth.tsx

@@ -10,6 +10,7 @@ import { wxLogin } from "@/services/user";
 import { ColorType } from "@/context/themes/color";
 import { ChooseScenarioBtn } from "@/features/common/SpecBtns";
 import { useTranslation } from "react-i18next";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 export default function Page() {
     const dispatch = useDispatch();
@@ -60,9 +61,7 @@ export default function Page() {
     }
 
     function createAccount() {
-        Taro.navigateTo({
-            url: '/pages/account/Auth'
-        })
+        jumpPage('/pages/account/Auth')
     }
 
     return <View className="container choose_container">

+ 2 - 4
src/pages/account/Login.tsx

@@ -4,6 +4,7 @@ import SingleSelect from "@/components/input/SingleSelect";
 import Rings from '@components/view/Rings';
 import { ButtonType,ComponentStatus } from "../../utils/types";
 import Taro from "@tarojs/taro";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 export default function Login(){
     const  array:any[] = []
@@ -12,10 +13,7 @@ export default function Login(){
     array.push(<Rings  radius={50} strokeWidth={5} color={"pink"}/>)
 
     function goAuth(){
-        // console.log('goAuth')
-        Taro.navigateTo({
-            url:'/pages/account/Auth'
-        })
+        jumpPage('/pages/account/Auth')
     }
 
     return (

+ 23 - 22
src/pages/account/Profile.tsx

@@ -11,7 +11,11 @@ import Layout from "@/components/layout/layout";
 import { useTranslation } from "react-i18next";
 import TableCell from "@/components/layout/TableCell";
 import { useEffect, useState } from "react";
-
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
+let useNavigation;
+if (process.env.TARO_ENV=='rn'){
+    useNavigation = require("@react-navigation/native").useNavigation
+}
 
 export default function Page() {
     const dispatch = useDispatch();
@@ -19,6 +23,11 @@ export default function Page() {
     const user = useSelector((state: any) => state.user);
     const [switchOn, setSwitchOn] = useState(false)
 
+    let navigation;
+    if (useNavigation){
+        navigation = useNavigation()
+    }
+
     useEffect(() => {
         if (process.env.TARO_ENV == 'weapp') {
             var status = Taro.getStorageSync('isDebug')
@@ -41,12 +50,6 @@ export default function Page() {
         global.isDebug = e.detail.value
     }
 
-    function tapLogin() {
-        Taro.navigateTo({
-            url: '/pages/account/ChooseAuth'
-        })
-    }
-
     useDidShow(() => {
         global.updateTab(3)
     })
@@ -77,16 +80,14 @@ export default function Page() {
     }
 
     function tapProfile(e) {
-        e.stopPropagation()
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
         if (user.isLogin) {
-            Taro.navigateTo({
-                url: '/pages/account/ProfileSetting'
-            })
+            jumpPage('/pages/account/ProfileSetting')
         }
         else {
-            Taro.navigateTo({
-                url: '/pages/account/ChooseAuth'
-            })
+            jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
         }
     }
 
@@ -95,19 +96,19 @@ export default function Page() {
 
         }
         else {
-            Taro.navigateTo({
-                url: '/pages/account/ChooseAuth'
-            })
-            e.stopPropagation()
+            jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
+            if (process.env.TARO_ENV == 'weapp') {
+                e.stopPropagation()
+            }
         }
 
     }
 
     function goSetting(e) {
-        Taro.navigateTo({
-            url: '/pages/account/Setting'
-        })
-        e.stopPropagation()
+        jumpPage('/pages/account/Setting')
+        if (process.env.TARO_ENV == 'weapp') {
+            e.stopPropagation()
+        }
     }
 
     console.log(user.avatar)

+ 2 - 3
src/pages/account/ProfileSetting.tsx

@@ -10,6 +10,7 @@ import { useTranslation } from "react-i18next";
 import { baseUrl } from "@/services/http/api";
 import { updateSuccess } from "@/store/user";
 import TableCell from "@/components/layout/TableCell";
+import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 
 export default function Page() {
     const dispatch = useDispatch();
@@ -23,9 +24,7 @@ export default function Page() {
     }, [])
 
     function editNickname() {
-        Taro.navigateTo({
-            url: '/pages/account/EditPage'
-        })
+        jumpPage('/pages/account/EditPage')
     }
 
     function chooseAvatar(e) {

+ 22 - 16
src/pages/clock/Clock.rn.tsx

@@ -40,15 +40,25 @@ import Header from '@/components/layout/Header'
 import { TimeFormatter } from '@/utils/time_format'
 import NoData from '@/components/view/NoData'
 import { ColorType } from '@/context/themes/color'
+import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
 // import TabBar from '../../components/Tabbar';
 
 // import Rings from '@components/view/Rings';
 
+let useNavigation;
+if (process.env.TARO_ENV=='rn'){
+    useNavigation = require("@react-navigation/native").useNavigation
+}
+
 
 export default function IndexPage() {
-    return <View >
-      <View style={{width:100,height:100,borderWidth:2,borderColor:'pink'}}></View>
-    </View>
+  let navigation;
+    if (useNavigation){
+        navigation = useNavigation()
+    }
+  return <View >
+    <View style={{ width: 100, height: 100, borderWidth: 2, borderColor: 'pink' }}></View>
+  </View>
   const dispatch = useDispatch();
   const { t } = useTranslation()
   const [checkData, setCheckData] = useState(null)
@@ -71,7 +81,7 @@ export default function IndexPage() {
   const [modalDetail2, setModalDetail2] = useState<any>({})
   const [showSingleFastEnd, setShowSingleFastEnd] = useState(false)
   const [consoleStatus, setConsoleStatus] = useState(consoleData.status)
-  
+
 
   global.dispatch = dispatch;
 
@@ -239,13 +249,11 @@ export default function IndexPage() {
 
   function tapClock() {
     if (!user.isLogin) {
-      Taro.navigateTo({
-        url: '/pages/account/ChooseAuth'
-      })
+      jumpPage('/pages/account/ChooseAuth','ChooseAuth',navigation)
     }
   }
 
-  
+
 
   function getCheckData() {
     getClocks().then(res => {
@@ -303,7 +311,7 @@ export default function IndexPage() {
     })
   }
 
-  
+
 
   function checkWXPubFollow() {
     wxPubFollow().then(res => {
@@ -322,7 +330,7 @@ export default function IndexPage() {
     }
   }
 
-  
+
 
   function schedule() {
     if (!user.isLogin) {
@@ -342,7 +350,7 @@ export default function IndexPage() {
     return isNeed
   }
 
-  
+
 
   global.showClockModal = (isShow: boolean, detail: any) => {
     setShowModal(isShow)
@@ -367,7 +375,7 @@ export default function IndexPage() {
     return <View />
   }
 
-  
+
 
   function consoleView() {
     if (!checkData) {
@@ -405,7 +413,7 @@ export default function IndexPage() {
     </View>
   }
 
-  
+
 
 
   function detail() {
@@ -436,9 +444,7 @@ export default function IndexPage() {
                 checkData && (checkData as any).latest_record &&
                 <SectionHeader top={48} bottom={24} title={t('feature.track_time_duration.record_fast_sleep.header.latest_record')}>
                   <Header title='' action={() => {
-                    Taro.navigateTo({
-                      url: '/pages/common/RecordsHistory?type=time&title=time'
-                    })
+                    jumpPage('/pages/common/RecordsHistory?type=time&title=time')
                   }} />
                 </SectionHeader>
               }

+ 15 - 8
src/pages/clock/Clock.weapp.tsx

@@ -40,10 +40,16 @@ import Header from '@/components/layout/Header'
 import { TimeFormatter } from '@/utils/time_format'
 import NoData from '@/components/view/NoData'
 import { ColorType } from '@/context/themes/color'
+import { jumpPage } from '@/features/trackTimeDuration/hooks/Common'
 // import TabBar from '../../components/Tabbar';
 
 // import Rings from '@components/view/Rings';
 
+let useNavigation;
+if (process.env.TARO_ENV == 'rn') {
+  useNavigation = require("@react-navigation/native").useNavigation
+}
+
 
 export default function IndexPage() {
   const dispatch = useDispatch();
@@ -69,6 +75,11 @@ export default function IndexPage() {
   const [showSingleFastEnd, setShowSingleFastEnd] = useState(false)
   const [consoleStatus, setConsoleStatus] = useState(consoleData.status)
 
+  let navigation;
+  if (useNavigation) {
+    navigation = useNavigation()
+  }
+
   global.dispatch = dispatch;
 
   global.checkData = () => {
@@ -235,9 +246,7 @@ export default function IndexPage() {
 
   function tapClock() {
     if (!user.isLogin) {
-      Taro.navigateTo({
-        url: '/pages/account/ChooseAuth'
-      })
+      jumpPage('/pages/account/ChooseAuth', 'ChooseAuth', navigation)
     }
   }
 
@@ -299,9 +308,9 @@ export default function IndexPage() {
 
   function checkWXPubFollow() {
     var params;
-    if (global.forceRefreshWXPub){
+    if (global.forceRefreshWXPub) {
       params = {
-        force_refresh:true
+        force_refresh: true
       }
     }
     global.forceRefreshWXPub = false
@@ -428,9 +437,7 @@ export default function IndexPage() {
                 checkData && (checkData as any).latest_record &&
                 <SectionHeader top={48} bottom={24} title={t('feature.track_time_duration.record_fast_sleep.header.latest_record')}>
                   <Header title='' action={() => {
-                    Taro.navigateTo({
-                      url: '/pages/common/RecordsHistory?type=time&title=time'
-                    })
+                    jumpPage('/pages/common/RecordsHistory?type=time&title=time')
                   }} />
                 </SectionHeader>
               }

+ 2 - 3
src/pages/index/index.tsx

@@ -10,6 +10,7 @@ import { getInfoSuccess } from '@/store/user';
 import { wxPubFollow } from '@/services/permission';
 import { staticResources } from '@/services/common';
 import { use } from 'i18next';
+import { jumpPage } from '@/features/trackTimeDuration/hooks/Common';
 // import TabBar from '../../components/Tabbar';
 
 export default function IndexPage() {
@@ -56,9 +57,7 @@ export default function IndexPage() {
       showCancel: true,
       success(result) {
         if (result.confirm) {
-          Taro.navigateTo({
-            url: '/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url,
-          })
+          jumpPage('/pages/common/H5?title=fast16cc 关注服务号&url=' + resource[0].url)
         }
       },
     })