Explorar el Código

app开始适配

leon hace 1 año
padre
commit
c516dbcfa8

+ 4 - 3
src/_health/pages/log_time.tsx

@@ -105,9 +105,10 @@ export default function LogTime() {
         if (process.env.TARO_ENV == 'rn') {
             AppState.addEventListener('change', handleAppStateChange);
         }
-        Taro.onAppShow(() => {
-            setCount(count => count + 1)
-        })
+        if (process.env.TARO_ENV == 'weapp')
+            Taro.onAppShow(() => {
+                setCount(count => count + 1)
+            })
 
     }, [])
 

+ 6 - 1
src/_record/components/ring_progress.tsx

@@ -1,9 +1,14 @@
 import { MainColorType } from "@/context/themes/color";
 import { rpxToPx } from "@/utils/tools";
-import { Canvas } from "@tarojs/components";
+// import { Canvas } from "@tarojs/components";
 import Taro, { useReady } from "@tarojs/taro";
 import { useEffect, useRef, useState } from "react";
 
+let Canvas
+
+if (process.env.TARO_ENV == 'weapp'){
+    Canvas = require("@tarojs/components").Canvas
+}
 export default function RingProgress(props: {
     canvasId?: string;
     bgRing: any;

+ 16 - 0
src/_record/pages/log_record.scss

@@ -198,6 +198,7 @@
     }
 }
 
+/* #ifdef weapp */
 .share_bg {
     position: fixed;
     left: 0;
@@ -211,7 +212,22 @@
     align-items: center;
     justify-content: center;
 }
+/* #endif */
 
+/* #ifdef rn */
+.share_bg {
+    position: fixed;
+    left: 0;
+    top: 0;
+    width: 100vw;
+    height: 100vh;
+    z-index: 100;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
+/* #endif */
 
 
 .share_card1 {

+ 3 - 3
src/_record/pages/log_record.tsx

@@ -21,7 +21,7 @@ import { jumpPage } from "@/features/trackTimeDuration/hooks/Common";
 import ChooseActions from "@/pages/clock/components/choose_actions";
 import PickerCard from "../components/picker_card";
 import { IconCamera, IconClock } from "../components/record_icon";
-import QuickLog from "../components/quick_log";
+// import QuickLog from "../components/quick_log";
 import FollowInfo from "@/_moment/components/follow_info";
 
 let useRoute;
@@ -542,9 +542,9 @@ export default function LogRecord() {
     }
 
     if (quick) {
-        return <QuickLog tag={chooseTitle} scenario={scenario} updateTag={() => {
+        // return <QuickLog tag={chooseTitle} scenario={scenario} updateTag={() => {
 
-        }} />
+        // }} />
     }
 
     return <View style={{ position: 'relative', overflow: showChoose ? 'hidden' : 'auto' }}>

+ 24 - 4
src/_record/pages/time_record.scss

@@ -103,9 +103,9 @@
     opacity: 0;
 }
 
-.end_card_show{
+.end_card_show {
     background-color: rgba($color: #ffffff, $alpha: 0.25);
-    animation: highlightShowAni 3s  linear forwards;
+    animation: highlightShowAni 3s linear forwards;
     opacity: 0;
 }
 
@@ -125,11 +125,12 @@
     0% {
         opacity: 0;
     }
-    10%{
+
+    10% {
         opacity: 1;
     }
 
-    90%{
+    90% {
         opacity: 1;
     }
 
@@ -154,6 +155,7 @@
     top: 48px;
 }
 
+/* #ifdef weapp */
 .share_bg {
     position: fixed;
     left: 0;
@@ -168,6 +170,24 @@
     justify-content: center;
 }
 
+/* #endif */
+
+/* #ifdef rn */
+.share_bg {
+    position: fixed;
+    left: 0;
+    top: 0;
+    width: 100vw;
+    height: 100vh;
+    z-index: 100;
+    display: flex;
+    flex-direction: column;
+    align-items: center;
+    justify-content: center;
+}
+
+/* #endif */
+
 .share_card {
     width: 698px;
     height: 932px;

+ 10 - 8
src/app.tsx

@@ -39,15 +39,17 @@ const App: React.FC<PropsWithChildren> = ({ children }) => {
   global.hideRingIcon = false
 
   Taro.setStorage({ key: 'showedDisqualifiedAlert', data: false })
+  if (process.env.TARO_ENV == 'weapp') {
+    Taro.onAppShow((res) => {
+      if (res.shareTicket) {
+        global.shareTicket = res.shareTicket
+      }
+      else {
+        global.shareTicket = null
+      }
+    })
+  }
 
-  Taro.onAppShow((res) => {
-    if (res.shareTicket) {
-      global.shareTicket = res.shareTicket
-    }
-    else {
-      global.shareTicket = null
-    }
-  })
 
   useLaunch((res) => {
     if (res.shareTicket) {

+ 4 - 3
src/pages/clock/ClockNew.tsx

@@ -167,9 +167,10 @@ export default function ClockNew(props: { children: any, onScroll: any }) {
         if (process.env.TARO_ENV == 'rn') {
             AppState.addEventListener('change', handleAppStateChange);
         }
-        Taro.onAppShow(() => {
-            refreshData()
-        })
+        if (process.env.TARO_ENV == 'weapp')
+            Taro.onAppShow(() => {
+                refreshData()
+            })
         setInterval(() => {
             setCount(index => index + 1)
             healthRef.current.refreshs.map((item) => {

+ 7 - 1
src/pages/moment/moment_detail_share.tsx

@@ -1,9 +1,15 @@
 import { useDispatch, useSelector } from "react-redux";
 import { useEffect, useState } from "react";
-import { View, Canvas } from "@tarojs/components";
+import { View } from "@tarojs/components";
 import Taro, { useDidShow } from "@tarojs/taro";
 import { MainColorType } from "@/context/themes/color";
 
+let Canvas
+
+if (process.env.TARO_ENV == 'weapp'){
+    Canvas = require("@tarojs/components").Canvas
+}
+
 export default function MomentDetailShare(props: { user: any, canvas_id?: string, cover?: string, btnColor?: string }) {
     const user = props.user;
 

+ 6 - 36
src/pages/rn/RNMain.tsx

@@ -5,22 +5,16 @@ import { createStackNavigator } from '@react-navigation/stack';
 
 import Clock from '../clock/Clock'
 import Metric from '../metric/Metric'
-import Workout from '../workout/Workout'
+
 import Profile from '../account/Profile'
 import ChooseAuth from '@/_account/pages/ChooseAuth'
 import Auth from '@/_account/pages/Auth'
 import Setting from '@/_account/pages/Setting'
-import SetSchedule from '@/pages/clock/SetSchedule'
-import ChooseScenario from '@/pages/clock/ChooseScenario'
-import Suggest from '../clock/Suggest';
-import SetGoal from '../clock/SetGoal';
+
 import RecordsHistory from '@/pages/common/RecordsHistory'
 import ProfileSetting from '@/_account/pages/ProfileSetting'
 import EditPage from '@/_account/pages/EditPage'
-import Food from '@/pages/food/Food'
-import Working from '@/pages/workout/Working'
-import WorkoutDetail from '@/pages/workout/WorkoutDetail'
-import StreakDetail from '@/pages/clock/StreakDetail';
+
 import H5 from '@/pages/common/H5';
 import NotificationSetting from '@/pages/notification/setting';
 import { Image, PixelRatio, StatusBar } from 'react-native';
@@ -264,9 +258,7 @@ export default function RNMain() {
         <Stack.Screen name='Auth' component={Auth} options={{
           headerBackTitle: ' '
         }} />
-        <Stack.Screen name='Food' component={Food} options={{
-          headerBackTitle: ' '
-        }} />
+
         <Stack.Screen name='Clock' component={Clock} options={{
           headerBackTitle: ' '
         }} />
@@ -276,45 +268,23 @@ export default function RNMain() {
         <Stack.Screen name='H5' component={H5} options={{
           headerBackTitle: ' '
         }} />
-        <Stack.Screen name='ChooseScenario' component={ChooseScenario} options={{
-          headerBackTitle: ' '
-        }} />
+
         <Stack.Screen name='RecordsHistory' component={RecordsHistory} options={{
           headerBackTitle: ' '
         }} />
-        <Stack.Screen name='SetSchedule' component={SetSchedule} options={{
-          headerBackTitle: ' '
-        }} />
+
         <Stack.Screen name='ProfileSetting' component={ProfileSetting} options={{
           headerBackTitle: ' '
         }} />
         <Stack.Screen name='EditPage' component={EditPage} options={{
           headerBackTitle: ' '
         }} />
-        <Stack.Screen name='Working' component={Working} options={{
-          headerBackTitle: ' '
-        }} />
-        <Stack.Screen name='WorkoutDetail' component={WorkoutDetail} options={{
-          headerBackTitle: ' '
-        }} />
-        <Stack.Screen name='StreakDetail' component={StreakDetail} options={{
-          headerBackTitle: ' '
-        }} />
-        <Stack.Screen name='Suggest' component={Suggest} options={{
-          headerBackTitle: ' '
-        }} />
-        <Stack.Screen name='SetGoal' component={SetGoal} options={{
-          headerBackTitle: ' '
-        }} />
         <Stack.Screen name='ProductList' component={ProductList} options={{
           headerBackTitle: ' '
         }} />
         <Stack.Screen name='map' component={map} options={{
           headerBackTitle: ' '
         }} />
-        <Stack.Screen name='Album' component={Album} options={{
-          headerBackTitle: ' '
-        }} />
         <Stack.Screen name='Journal' component={Journal} options={{
           headerBackTitle: ' '
         }} />

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

@@ -1,4 +1,4 @@
-const online = process.env.TARO_ENV == 'weapp' ? true : false;
+const online = process.env.TARO_ENV == 'weapp' ? false : false;
 
 import { WX_VERSION as _WX_VERSION, APP_VERSION as _APP_VERSION, ANDROID_VERSION as _ANDROID_VERSION } from "../../../config/env";