From da8646156b8e2653b8a558d70865d2308762c026 Mon Sep 17 00:00:00 2001 From: xudan Date: Thu, 24 Jul 2025 09:16:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=AF=E7=94=A8=E6=96=B0=E6=9E=B6?= =?UTF-8?q?=E6=9E=84=E6=94=AF=E6=8C=81=EF=BC=8C=E6=9B=B4=E6=96=B0=20App=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=BB=A5=E6=A3=80=E6=B5=8B=20Fabric=20?= =?UTF-8?q?=E5=92=8C=20TurboModules=20=E7=8A=B6=E6=80=81=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98=E6=B8=85=E7=90=86=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.tsx | 41 ++++++++++++++++++++++++++++++++------- android/gradle.properties | 2 +- ios/Podfile | 6 +++++- 3 files changed, 40 insertions(+), 9 deletions(-) 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|