diff --git a/App.tsx b/App.tsx index 6a1916f..fd8e956 100644 --- a/App.tsx +++ b/App.tsx @@ -1,17 +1,42 @@ import React, { useEffect } from 'react'; import { NavigationContainer } from '@react-navigation/native'; -import AppNavigator from './src/navigation/AppNavigator'; - -import { TasksProvider } from './src/context/TasksContext'; import { ThemeProvider } from '@rneui/themed'; +import { TasksProvider } from './src/context/TasksContext'; +import AppNavigator from './src/navigation/AppNavigator'; import { clearCachedConfig } from './src/services/configService'; -export default function App() { +function App(): React.JSX.Element { + // 检测新架构 + useEffect(() => { + const globalAny = global as any; + const isFabricEnabled = globalAny.nativeFabricUIManager != null; + const isTurboModuleEnabled = globalAny.__turboModuleProxy != null; + + console.log('🏗️ 架构检测结果:'); + console.log( + 'Fabric (新渲染器):', + isFabricEnabled ? '✅ 已启用' : '❌ 未启用', + ); + console.log( + 'TurboModules (新模块系统):', + isTurboModuleEnabled ? '✅ 已启用' : '❌ 未启用', + ); + console.log( + '新架构状态:', + isFabricEnabled && isTurboModuleEnabled + ? '🎉 完全启用' + : '⚠️ 部分启用或未启用', + ); + }, []); + useEffect(() => { const clearCacheOnStart = async () => { - console.log('正在清除缓存的配置文件...'); - await clearCachedConfig(); - console.log('缓存已清除,将使用最新的 config.json。'); + try { + await clearCachedConfig(); + console.log('配置缓存已清理'); + } catch (error) { + console.error('清理配置缓存失败:', error); + } }; clearCacheOnStart(); @@ -27,3 +52,5 @@ export default function App() { ); } + +export default App; diff --git a/android/gradle.properties b/android/gradle.properties index 127f945..e979058 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -32,7 +32,7 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 # your application. You should enable this flag either if you want # to write custom TurboModules/Fabric components OR use libraries that # are providing them. -newArchEnabled=false +newArchEnabled=true # Use this property to enable or disable the Hermes JS engine. # If set to false, you will be using JSC instead. diff --git a/ios/Podfile b/ios/Podfile index 864448d..64c3120 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -20,7 +20,11 @@ target 'MyReactNativeApp' do use_react_native!( :path => config[:reactNativePath], # An absolute path to your application root. - :app_path => "#{Pod::Config.instance.installation_root}/.." + :app_path => "#{Pod::Config.instance.installation_root}/..", + # Enables Fabric renderer + :fabric_enabled => true, + # Enables the new architecture for iOS + :new_arch_enabled => true ) post_install do |installer|