/** * ModuleErrorFallback - 模块加载失败的兜底组件 */ import React from 'react'; import { View, Text, TouchableOpacity, StyleSheet } from 'react-native'; interface Props { moduleId: string; error: Error | null; onRetry: () => void; onGoHome?: () => void; } export function ModuleErrorFallback({ moduleId, error, onRetry, onGoHome, }: Props) { return ( {moduleId} 模块暂时无法使用 {error && ( {error.message || String(error)} )} 重试 {onGoHome && ( 返回首页 )} ); } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#fff', padding: 20, }, title: { fontSize: 20, fontWeight: 'bold', color: '#333', marginBottom: 16, textAlign: 'center', }, errorText: { fontSize: 14, color: '#d32f2f', marginBottom: 24, textAlign: 'center', padding: 12, backgroundColor: '#ffebee', borderRadius: 4, width: '100%', }, buttonContainer: { width: '100%', maxWidth: 300, }, button: { backgroundColor: '#007AFF', padding: 15, borderRadius: 8, marginVertical: 8, alignItems: 'center', }, buttonText: { color: '#fff', fontSize: 16, fontWeight: '600', }, });