|
@@ -1,6 +1,6 @@
|
|
import { View, ScrollView } from "@tarojs/components";
|
|
import { View, ScrollView } from "@tarojs/components";
|
|
-// import PageCustom from "@/components/page-custom/index";
|
|
|
|
-// import NavBarNormal from "@/components/nav-bar-normal/index";
|
|
|
|
|
|
+import NavBarNormal from "@/components/nav-bar-normal/index";
|
|
|
|
+import PageCustom from "@/components/page-custom/index";
|
|
import Taro, { useUnload } from "@tarojs/taro";
|
|
import Taro, { useUnload } from "@tarojs/taro";
|
|
import { useCurrentCharacter } from "@/store/characterStore";
|
|
import { useCurrentCharacter } from "@/store/characterStore";
|
|
import ChatMessage from "./components/chat-message";
|
|
import ChatMessage from "./components/chat-message";
|
|
@@ -12,6 +12,10 @@ import { useTextChat } from "@/store/textChat";
|
|
import { EAI_MODEL } from "@/consts/enum";
|
|
import { EAI_MODEL } from "@/consts/enum";
|
|
import type { TMessage, TRobotMessage } from "@/store/textChat";
|
|
import type { TMessage, TRobotMessage } from "@/store/textChat";
|
|
|
|
|
|
|
|
+import ChatWelcome from './components/chat-welcome'
|
|
|
|
+import IconArrowLeft from "@/components/icon/icon-arrow-left";
|
|
|
|
+import PersonalCard from './components/personal-card'
|
|
|
|
+
|
|
// 类型谓词函数
|
|
// 类型谓词函数
|
|
function isRobotMessage(message: TMessage | TRobotMessage): message is TRobotMessage {
|
|
function isRobotMessage(message: TMessage | TRobotMessage): message is TRobotMessage {
|
|
return 'robot' in message && 'reasoningContent' in message;
|
|
return 'robot' in message && 'reasoningContent' in message;
|
|
@@ -19,6 +23,7 @@ function isRobotMessage(message: TMessage | TRobotMessage): message is TRobotMes
|
|
|
|
|
|
export default function Index() {
|
|
export default function Index() {
|
|
const [deepThink, setDeepThink] = useState(EAI_MODEL.DeepseekChat);
|
|
const [deepThink, setDeepThink] = useState(EAI_MODEL.DeepseekChat);
|
|
|
|
+ const [showWelcome, setShowWelcome] = useState(true);
|
|
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
const [contentHeight, setContentHeight] = useState(0);
|
|
const [contentHeight, setContentHeight] = useState(0);
|
|
const [scrollViewHeight, setScrollViewHeight] = useState(0);
|
|
const [scrollViewHeight, setScrollViewHeight] = useState(0);
|
|
@@ -56,7 +61,7 @@ export default function Index() {
|
|
if(res.height <= 0){
|
|
if(res.height <= 0){
|
|
return setKeyboardHeight(0);
|
|
return setKeyboardHeight(0);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ setShowWelcome(false)
|
|
setKeyboardHeight(res.height - 24);
|
|
setKeyboardHeight(res.height - 24);
|
|
});
|
|
});
|
|
|
|
|
|
@@ -71,13 +76,13 @@ export default function Index() {
|
|
if (scrollViewRef.current) {
|
|
if (scrollViewRef.current) {
|
|
const query = Taro.createSelectorQuery();
|
|
const query = Taro.createSelectorQuery();
|
|
// 获取聊天内容高度
|
|
// 获取聊天内容高度
|
|
- query.select('#message-list').boundingClientRect((rect: any) => {
|
|
|
|
|
|
+ query.select('#messageList').boundingClientRect((rect: any) => {
|
|
if (rect) {
|
|
if (rect) {
|
|
setContentHeight(rect.height);
|
|
setContentHeight(rect.height);
|
|
}
|
|
}
|
|
}).exec();
|
|
}).exec();
|
|
// 获取滚动容器高度
|
|
// 获取滚动容器高度
|
|
- query.select('#scroll-view').boundingClientRect((rect: any) => {
|
|
|
|
|
|
+ query.select('#scrollView').boundingClientRect((rect: any) => {
|
|
if (rect) {
|
|
if (rect) {
|
|
setScrollViewHeight(rect.height);
|
|
setScrollViewHeight(rect.height);
|
|
}
|
|
}
|
|
@@ -110,15 +115,25 @@ export default function Index() {
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
+ const renderNavLeft = ()=> {
|
|
|
|
+ return (
|
|
|
|
+ <View className="flex items-center gap-8">
|
|
|
|
+ <IconArrowLeft />
|
|
|
|
+ <View className={showWelcome ? 'hidden' : 'block'}>
|
|
|
|
+ <PersonalCard size="mini" />
|
|
|
|
+ </View>
|
|
|
|
+ </View>
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
|
|
return (
|
|
return (
|
|
- <View className="h-screen bg-gray-page">
|
|
|
|
- <View className="flex flex-col w-full h-screen pt-24 pb-138" style={{marginTop: `${marginTopOffset}px`}}>
|
|
|
|
|
|
+ <PageCustom>
|
|
|
|
+ <NavBarNormal scrollFadeIn leftColumn={renderNavLeft}></NavBarNormal>
|
|
|
|
+ <View className="flex flex-col w-full h-screen">
|
|
<ScrollView
|
|
<ScrollView
|
|
ref={scrollViewRef}
|
|
ref={scrollViewRef}
|
|
scrollY
|
|
scrollY
|
|
- id="scroll-view"
|
|
|
|
|
|
+ id="scrollView"
|
|
style={{
|
|
style={{
|
|
flex: 1,
|
|
flex: 1,
|
|
height: "1px", // 高度自适应
|
|
height: "1px", // 高度自适应
|
|
@@ -126,7 +141,8 @@ export default function Index() {
|
|
scrollTop={scrollTop}
|
|
scrollTop={scrollTop}
|
|
scrollWithAnimation
|
|
scrollWithAnimation
|
|
>
|
|
>
|
|
- <View id="message-list" className="flex flex-col gap-8 px-18 pb-40">
|
|
|
|
|
|
+ {showWelcome && <ChatWelcome/>}
|
|
|
|
+ <View id="messageList" className="flex flex-col gap-8 px-18 pb-140">
|
|
{messageList.map((message) => {
|
|
{messageList.map((message) => {
|
|
const robotMessage = isRobotMessage(message) ? message : null;
|
|
const robotMessage = isRobotMessage(message) ? message : null;
|
|
return (
|
|
return (
|
|
@@ -140,6 +156,7 @@ export default function Index() {
|
|
})}
|
|
})}
|
|
</View>
|
|
</View>
|
|
</ScrollView>
|
|
</ScrollView>
|
|
|
|
+ <View className="h-140 w-10"></View>
|
|
<View
|
|
<View
|
|
className="fixed left-0 right-0 bottom-0 min-h-130 z-50"
|
|
className="fixed left-0 right-0 bottom-0 min-h-130 z-50"
|
|
style={{
|
|
style={{
|
|
@@ -156,11 +173,9 @@ export default function Index() {
|
|
>
|
|
>
|
|
深度思考(R1)
|
|
深度思考(R1)
|
|
</View>
|
|
</View>
|
|
- {character && (
|
|
|
|
- <InputBar aiModel={deepThink} character={character}></InputBar>
|
|
|
|
- )}
|
|
|
|
|
|
+ <InputBar aiModel={deepThink} character={null}></InputBar>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
- </View>
|
|
|
|
|
|
+ </PageCustom>
|
|
);
|
|
);
|
|
}
|
|
}
|