chore: 注释websocket
This commit is contained in:
parent
3047215ada
commit
b3b31baab2
@ -3,10 +3,9 @@ import Chat from "@/components/ask/chat";
|
|||||||
import AskHello from "@/components/ask/hello";
|
import AskHello from "@/components/ask/hello";
|
||||||
import SendMessage from "@/components/ask/send";
|
import SendMessage from "@/components/ask/send";
|
||||||
import { ThemedText } from "@/components/ThemedText";
|
import { ThemedText } from "@/components/ThemedText";
|
||||||
import { fetchApi } from "@/lib/server-api-util";
|
|
||||||
import { getWebSocketErrorMessage, getWebSocketManager, WsMessage } from "@/lib/websocket-util";
|
|
||||||
import { Assistant, Message } from "@/types/ask";
|
|
||||||
import { useWebSocketStreamHandler } from "@/hooks/useWebSocketStreamHandler";
|
import { useWebSocketStreamHandler } from "@/hooks/useWebSocketStreamHandler";
|
||||||
|
import { fetchApi } from "@/lib/server-api-util";
|
||||||
|
import { Message } from "@/types/ask";
|
||||||
import { useFocusEffect, useLocalSearchParams, useRouter } from "expo-router";
|
import { useFocusEffect, useLocalSearchParams, useRouter } from "expo-router";
|
||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@ -141,20 +140,20 @@ export default function AskScreen() {
|
|||||||
enableBatching: false // AskScreen使用实时模式
|
enableBatching: false // AskScreen使用实时模式
|
||||||
});
|
});
|
||||||
|
|
||||||
useFocusEffect(
|
// useFocusEffect(
|
||||||
useCallback(() => {
|
// useCallback(() => {
|
||||||
isMountedRef.current = true;
|
// isMountedRef.current = true;
|
||||||
|
|
||||||
// 订阅WebSocket消息
|
// // 订阅WebSocket消息
|
||||||
const unsubscribe = subscribeToWebSocket();
|
// const unsubscribe = subscribeToWebSocket();
|
||||||
|
|
||||||
return () => {
|
// return () => {
|
||||||
// 取消订阅和执行清理
|
// // 取消订阅和执行清理
|
||||||
unsubscribe();
|
// unsubscribe();
|
||||||
cleanup();
|
// cleanup();
|
||||||
};
|
// };
|
||||||
}, [subscribeToWebSocket, cleanup])
|
// }, [subscribeToWebSocket, cleanup])
|
||||||
);
|
// );
|
||||||
|
|
||||||
// 创建动画样式
|
// 创建动画样式
|
||||||
const welcomeStyle = useAnimatedStyle(() => {
|
const welcomeStyle = useAnimatedStyle(() => {
|
||||||
@ -222,70 +221,70 @@ export default function AskScreen() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
|
<View style={[styles.container, { paddingTop: insets.top, paddingBottom: insets.bottom }]}>
|
||||||
{/* 导航栏 */}
|
{/* 导航栏 */}
|
||||||
<View style={[styles.navbar, isHello && styles.hiddenNavbar]}>
|
<View style={[styles.navbar, isHello && styles.hiddenNavbar]}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.backButton}
|
style={styles.backButton}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
try {
|
try {
|
||||||
if (TextInput.State?.currentlyFocusedInput) {
|
if (TextInput.State?.currentlyFocusedInput) {
|
||||||
const input = TextInput.State.currentlyFocusedInput();
|
const input = TextInput.State.currentlyFocusedInput();
|
||||||
if (input) input.blur();
|
if (input) input.blur();
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.log('失去焦点失败:', error);
|
|
||||||
}
|
}
|
||||||
Keyboard.dismiss();
|
} catch (error) {
|
||||||
router.push('/memo-list');
|
console.log('失去焦点失败:', error);
|
||||||
}}
|
}
|
||||||
>
|
Keyboard.dismiss();
|
||||||
<ReturnArrow />
|
router.push('/memo-list');
|
||||||
</TouchableOpacity>
|
}}
|
||||||
<ThemedText style={styles.title} onPress={() => { router.push('/owner') }}>MemoWake</ThemedText>
|
>
|
||||||
<View style={styles.placeholder} />
|
<ReturnArrow />
|
||||||
|
</TouchableOpacity>
|
||||||
|
<ThemedText style={styles.title} onPress={() => { router.push('/owner') }}>MemoWake</ThemedText>
|
||||||
|
<View style={styles.placeholder} />
|
||||||
|
</View>
|
||||||
|
|
||||||
|
<View style={styles.contentContainer}>
|
||||||
|
{/* 欢迎页面 */}
|
||||||
|
<Animated.View
|
||||||
|
style={[styles.absoluteView, welcomeStyle, { zIndex: 1 }]}
|
||||||
|
>
|
||||||
|
<AskHello setUserMessages={setUserMessages} setConversationId={setConversationId} setIsHello={setIsHello} />
|
||||||
|
</Animated.View>
|
||||||
|
|
||||||
|
{/* 聊天页面 */}
|
||||||
|
<Animated.View
|
||||||
|
style={[styles.absoluteView, chatStyle, { zIndex: 0 }]}
|
||||||
|
>
|
||||||
|
<Chat
|
||||||
|
ref={chatListRef}
|
||||||
|
userMessages={userMessages}
|
||||||
|
sessionId={sessionId}
|
||||||
|
setSelectedImages={setSelectedImages}
|
||||||
|
selectedImages={selectedImages}
|
||||||
|
style={styles.chatContainer}
|
||||||
|
contentContainerStyle={styles.chatContentContainer}
|
||||||
|
showsVerticalScrollIndicator={false}
|
||||||
|
// onContentSizeChange={() => scrollToEnd()}
|
||||||
|
/>
|
||||||
|
</Animated.View>
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{/* 输入框区域 */}
|
||||||
|
<KeyboardAvoidingView
|
||||||
|
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
||||||
|
keyboardVerticalOffset={0} >
|
||||||
|
<View style={styles.inputContainer} key={conversationId}>
|
||||||
|
<SendMessage
|
||||||
|
setIsHello={setIsHello}
|
||||||
|
conversationId={conversationId}
|
||||||
|
setConversationId={setConversationId}
|
||||||
|
setUserMessages={setUserMessages}
|
||||||
|
selectedImages={selectedImages}
|
||||||
|
setSelectedImages={setSelectedImages}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
</KeyboardAvoidingView>
|
||||||
<View style={styles.contentContainer}>
|
|
||||||
{/* 欢迎页面 */}
|
|
||||||
<Animated.View
|
|
||||||
style={[styles.absoluteView, welcomeStyle, { zIndex: 1 }]}
|
|
||||||
>
|
|
||||||
<AskHello setUserMessages={setUserMessages} setConversationId={setConversationId} setIsHello={setIsHello} />
|
|
||||||
</Animated.View>
|
|
||||||
|
|
||||||
{/* 聊天页面 */}
|
|
||||||
<Animated.View
|
|
||||||
style={[styles.absoluteView, chatStyle, { zIndex: 0 }]}
|
|
||||||
>
|
|
||||||
<Chat
|
|
||||||
ref={chatListRef}
|
|
||||||
userMessages={userMessages}
|
|
||||||
sessionId={sessionId}
|
|
||||||
setSelectedImages={setSelectedImages}
|
|
||||||
selectedImages={selectedImages}
|
|
||||||
style={styles.chatContainer}
|
|
||||||
contentContainerStyle={styles.chatContentContainer}
|
|
||||||
showsVerticalScrollIndicator={false}
|
|
||||||
// onContentSizeChange={() => scrollToEnd()}
|
|
||||||
/>
|
|
||||||
</Animated.View>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
{/* 输入框区域 */}
|
|
||||||
<KeyboardAvoidingView
|
|
||||||
behavior={Platform.OS === "ios" ? "padding" : "height"}
|
|
||||||
keyboardVerticalOffset={0} >
|
|
||||||
<View style={styles.inputContainer} key={conversationId}>
|
|
||||||
<SendMessage
|
|
||||||
setIsHello={setIsHello}
|
|
||||||
conversationId={conversationId}
|
|
||||||
setConversationId={setConversationId}
|
|
||||||
setUserMessages={setUserMessages}
|
|
||||||
selectedImages={selectedImages}
|
|
||||||
setSelectedImages={setSelectedImages}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</KeyboardAvoidingView>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user