diff --git a/app/(tabs)/statistics.tsx b/app/(tabs)/statistics.tsx index 8201d4f..3114e8a 100644 --- a/app/(tabs)/statistics.tsx +++ b/app/(tabs)/statistics.tsx @@ -424,6 +424,19 @@ export default function ExploreScreen() { handler: async () => { try { console.log('后台任务:更新健康数据和检查压力水平...'); + + // 发送测试通知,验证后台任务是否执行 + await notificationService.sendImmediateNotification({ + title: '后台任务测试 🔔', + body: `任务执行时间: ${new Date().toLocaleTimeString('zh-CN')}`, + data: { + type: 'background_task_test', + timestamp: new Date().toISOString(), + }, + sound: true, + priority: 'high' + }); + // 后台任务只更新健康数据,强制刷新以获取最新数据 await loadHealthData(undefined, true); diff --git a/app/auth/login.tsx b/app/auth/login.tsx index beb41e3..42833a3 100644 --- a/app/auth/login.tsx +++ b/app/auth/login.tsx @@ -138,20 +138,6 @@ export default function LoginScreen() { } }, [appleAvailable, router, searchParams?.redirectParams, searchParams?.redirectTo]); - const onGuestLogin = useCallback(() => { - // 游客继续:若有 redirect 则前往,无则返回 - const to = searchParams?.redirectTo as string | undefined; - const paramsJson = searchParams?.redirectParams as string | undefined; - let parsedParams: Record | undefined; - if (paramsJson) { - try { parsedParams = JSON.parse(paramsJson); } catch { } - } - if (to) { - router.replace({ pathname: to, params: parsedParams } as any); - } else { - router.back(); - } - }, [router, searchParams?.redirectParams, searchParams?.redirectTo]); // 登录按钮不再因未勾选协议而禁用,仅在加载中禁用 diff --git a/components/NutritionRecordCard.tsx b/components/NutritionRecordCard.tsx index a968544..6174e2a 100644 --- a/components/NutritionRecordCard.tsx +++ b/components/NutritionRecordCard.tsx @@ -5,7 +5,7 @@ import { Ionicons } from '@expo/vector-icons'; import dayjs from 'dayjs'; import React, { useMemo, useRef, useState } from 'react'; import { Alert, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; -import { Swipeable } from 'react-native-gesture-handler'; +import { RectButton, Swipeable } from 'react-native-gesture-handler'; export type NutritionRecordCardProps = { record: DietRecord; @@ -53,6 +53,9 @@ export function NutritionRecordCard({ // 左滑删除相关 const swipeableRef = useRef(null); + // 添加滑动状态管理,防止滑动时触发点击事件 + const [isSwiping, setIsSwiping] = useState(false); + // 营养数据统计 const nutritionStats = useMemo(() => { return [ @@ -80,6 +83,26 @@ export function NutritionRecordCard({ const mealTypeColor = MEAL_TYPE_COLORS[record.mealType]; const mealTypeLabel = MEAL_TYPE_LABELS[record.mealType]; + // 处理点击事件,只有在非滑动状态下才触发 + const handlePress = () => { + if (!isSwiping && onPress) { + onPress(); + } + }; + + // 处理滑动开始 + const handleSwipeableWillOpen = () => { + setIsSwiping(true); + }; + + // 处理滑动结束 + const handleSwipeableClose = () => { + // 延迟重置滑动状态,防止滑动结束时立即触发点击 + setTimeout(() => { + setIsSwiping(false); + }, 100); + }; + // 处理删除操作 const handleDelete = () => { Alert.alert( @@ -123,14 +146,16 @@ export function NutritionRecordCard({ renderRightActions={renderRightActions} rightThreshold={40} overshootRight={false} + onSwipeableWillOpen={handleSwipeableWillOpen} + onSwipeableClose={handleSwipeableClose} > - {/* 主要内容区域 - 水平布局 */} @@ -186,7 +211,7 @@ export function NutritionRecordCard({ - +