feat: 优化后台任务管理,添加系统权限和用户偏好的完整检查,增强通知功能

This commit is contained in:
richarjiang
2025-09-04 18:23:05 +08:00
parent 6c21c4b448
commit cb89ee7bc2
5 changed files with 217 additions and 108 deletions

View File

@@ -15,6 +15,7 @@ import { useAppDispatch, useAppSelector } from '@/hooks/redux';
import { useAuthGuard } from '@/hooks/useAuthGuard';
import { useBackgroundTasks } from '@/hooks/useBackgroundTasks';
import { notificationService } from '@/services/notifications';
import { backgroundTaskManager } from '@/services/backgroundTaskManager';
import { selectHealthDataByDate, setHealthData } from '@/store/healthSlice';
import { fetchDailyMoodCheckins, selectLatestMoodRecordByDate } from '@/store/moodSlice';
import { fetchDailyNutritionData, selectNutritionSummaryByDate } from '@/store/nutritionSlice';
@@ -37,7 +38,8 @@ import {
ScrollView,
StyleSheet,
Text,
View
View,
TouchableOpacity
} from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
@@ -618,6 +620,19 @@ export default function ExploreScreen() {
<View style={styles.headerTextContainer}>
<Text style={styles.headerTitle}></Text>
</View>
{/* 开发环境调试按钮 */}
{__DEV__ && (
<TouchableOpacity
style={styles.debugButton}
onPress={async () => {
console.log('🔧 手动触发后台任务测试...');
await backgroundTaskManager.debugExecuteBackgroundTask();
}}
>
<Text style={styles.debugButtonText}>🔧</Text>
</TouchableOpacity>
)}
</View>
</View>
@@ -813,6 +828,25 @@ const styles = StyleSheet.create({
fontWeight: '500',
color: '#192126',
},
debugButton: {
width: 32,
height: 32,
borderRadius: 16,
backgroundColor: '#FF6B6B',
alignItems: 'center',
justifyContent: 'center',
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.1,
shadowRadius: 4,
elevation: 3,
},
debugButtonText: {
fontSize: 12,
},
sectionTitle: {