重构应用程序架构,添加 OpenIM SDK 初始化和引导逻辑

This commit is contained in:
2026-03-09 06:45:47 +07:00
parent 8963f777ee
commit bbb0f88259
5 changed files with 115 additions and 23 deletions

View File

@@ -1,4 +1,3 @@
import OpenIMSDK from "@openim/rn-client-sdk";
import {
DarkTheme,
DefaultTheme,
@@ -6,11 +5,11 @@ import {
} from "@react-navigation/native";
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import RNFS from "react-native-fs";
import "react-native-reanimated";
import "../global.css";
import { useColorScheme } from "@/hooks/use-color-scheme";
import { AppBootstrapProvider } from "@/providers/app-bootstrap-provider";
export const unstable_settings = {
anchor: "(tabs)",
@@ -19,27 +18,18 @@ export const unstable_settings = {
export default function RootLayout() {
const colorScheme = useColorScheme();
RNFS.mkdir(RNFS.DocumentDirectoryPath + "/tmp");
OpenIMSDK.initSDK({
apiAddr: "https://openim-api.riwsan.com/api",
wsAddr: "wss://openim-api.riwsan.com/msg_gateway",
dataDir: RNFS.DocumentDirectoryPath + "/tmp",
logFilePath: RNFS.DocumentDirectoryPath + "/tmp",
logLevel: 5,
isLogStandardOutput: true,
});
return (
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen
name="modal"
options={{ presentation: "modal", title: "Modal" }}
/>
</Stack>
<StatusBar style="auto" />
</ThemeProvider>
<AppBootstrapProvider>
<ThemeProvider value={colorScheme === "dark" ? DarkTheme : DefaultTheme}>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen
name="modal"
options={{ presentation: "modal", title: "Modal" }}
/>
</Stack>
<StatusBar style="auto" />
</ThemeProvider>
</AppBootstrapProvider>
);
}