feat: 登录异常问题调整

This commit is contained in:
duanshuwen
2025-12-26 22:59:44 +08:00
parent dfadb06934
commit ea56695099
8 changed files with 115 additions and 187 deletions

View File

@@ -2,79 +2,42 @@
<view class="flex flex-col h-screen">
<!-- 顶部自定义导航栏 -->
<view class="header" :style="{ paddingTop: statusBarHeight + 'px' }">
<ChatTopNavBar
ref="topNavBarRef"
:mainPageDataModel="mainPageDataModel"
/>
<ChatTopNavBar ref="topNavBarRef" :mainPageDataModel="mainPageDataModel" />
</view>
<!-- 消息列表可滚动区域 -->
<scroll-view
class="main flex-full overflow-hidden scroll-y"
scroll-y
:scroll-top="scrollTop"
:scroll-with-animation="true"
@scroll="handleScroll"
@scrolltolower="handleScrollToLower"
>
<scroll-view class="main flex-full overflow-hidden scroll-y" scroll-y :scroll-top="scrollTop"
:scroll-with-animation="true" @scroll="handleScroll" @scrolltolower="handleScrollToLower">
<!-- welcome栏 -->
<ChatTopWelcome ref="welcomeRef" :mainPageDataModel="mainPageDataModel" />
<view
class="area-msg-list-content"
v-for="item in chatMsgList"
:key="item.msgId"
:id="item.msgId"
>
<view class="area-msg-list-content" v-for="item in chatMsgList" :key="item.msgId" :id="item.msgId">
<template v-if="item.msgType === MessageRole.AI">
<ChatCardAI
class="flex flex-justify-start"
:key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
:text="item.msg || ''"
:isLoading="item.isLoading"
>
<ChatCardAI class="flex flex-justify-start" :key="`ai-${item.msgId}-${item.msg ? item.msg.length : 0}`"
:text="item.msg || ''" :isLoading="item.isLoading">
<template #content v-if="item.toolCall">
<QuickBookingComponent
v-if="item.toolCall.componentName === CompName.quickBookingCard"
/>
<DiscoveryCardComponent
v-else-if="
item.toolCall.componentName === CompName.discoveryCard
"
/>
<CreateServiceOrder
v-else-if="
item.toolCall.componentName === CompName.callServiceCard
"
:toolCall="item.toolCall"
/>
<Feedback
v-else-if="
item.toolCall.componentName === CompName.feedbackCard
"
:toolCall="item.toolCall"
/>
<DetailCardCompontent
v-else-if="
item.toolCall.componentName ===
CompName.pictureAndCommodityCard
"
:toolCall="item.toolCall"
/>
<AddCarCrad
v-else-if="
item.toolCall.componentName === CompName.enterLicensePlateCard
"
:toolCall="item.toolCall"
/>
<QuickBookingComponent v-if="item.toolCall.componentName === CompName.quickBookingCard" />
<DiscoveryCardComponent v-else-if="
item.toolCall.componentName === CompName.discoveryCard
" />
<CreateServiceOrder v-else-if="
item.toolCall.componentName === CompName.callServiceCard
" :toolCall="item.toolCall" />
<Feedback v-else-if="
item.toolCall.componentName === CompName.feedbackCard
" :toolCall="item.toolCall" />
<DetailCardCompontent v-else-if="
item.toolCall.componentName ===
CompName.pictureAndCommodityCard
" :toolCall="item.toolCall" />
<AddCarCrad v-else-if="
item.toolCall.componentName === CompName.enterLicensePlateCard
" :toolCall="item.toolCall" />
</template>
<template #footer>
<!-- 这个是底部 -->
<AttachListComponent
v-if="item.question"
:question="item.question"
/>
<AttachListComponent v-if="item.question" :question="item.question" />
</template>
</ChatCardAI>
</template>
@@ -85,21 +48,15 @@
<template v-else>
<ChatCardOther class="flex flex-justify-center" :text="item.msg">
<ActivityListComponent
v-if="
mainPageDataModel.activityList &&
mainPageDataModel.activityList.length > 0
"
:activityList="mainPageDataModel.activityList"
/>
<ActivityListComponent v-if="
mainPageDataModel.activityList &&
mainPageDataModel.activityList.length > 0
" :activityList="mainPageDataModel.activityList" />
<RecommendPostsComponent
v-if="
mainPageDataModel.recommendTheme &&
mainPageDataModel.recommendTheme.length > 0
"
:recommendThemeList="mainPageDataModel.recommendTheme"
/>
<RecommendPostsComponent v-if="
mainPageDataModel.recommendTheme &&
mainPageDataModel.recommendTheme.length > 0
" :recommendThemeList="mainPageDataModel.recommendTheme" />
</ChatCardOther>
</template>
</view>
@@ -108,17 +65,9 @@
<!-- 输入框区域 -->
<view class="pb-safe-area">
<ChatQuickAccess />
<ChatInputArea
ref="inputAreaRef"
v-model="inputMessage"
:holdKeyboard="holdKeyboard"
:is-session-active="isSessionActive"
:stop-request="stopRequest"
@send="sendMessageAction"
@noHideKeyboard="handleNoHideKeyboard"
@keyboardShow="handleKeyboardShow"
@keyboardHide="handleKeyboardHide"
/>
<ChatInputArea ref="inputAreaRef" v-model="inputMessage" :holdKeyboard="holdKeyboard"
:is-session-active="isSessionActive" :stop-request="stopRequest" @send="sendMessageAction"
@noHideKeyboard="handleNoHideKeyboard" @keyboardShow="handleKeyboardShow" @keyboardHide="handleKeyboardHide" />
</view>
</view>
</template>
@@ -243,7 +192,7 @@ const handleScroll = ThrottleUtils.createThrottle(({ detail }) => {
}, 50);
// 处理滚动到底部事件
const handleScrollToLower = () => {};
const handleScrollToLower = () => { };
// 滚动到底部 - 优化版本,确保打字机效果始终可见
const scrollToBottom = () => {
@@ -474,53 +423,53 @@ const initWebSocket = async () => {
};
// 处理WebSocket消息
const handleWebSocketMessage = (data) => {
const aiMsgIndex = chatMsgList.value.length - 1;
if (!chatMsgList.value[aiMsgIndex] || aiMsgIndex < 0) {
console.error("处理WebSocket消息时找不到对应的AI消息项");
return;
}
const handleWebSocketMessage = (data) => {
const aiMsgIndex = chatMsgList.value.length - 1;
if (!chatMsgList.value[aiMsgIndex] || aiMsgIndex < 0) {
console.error("处理WebSocket消息时找不到对应的AI消息项");
return;
}
// 确保消息内容是字符串类型
if (data.content && typeof data.content !== "string") {
data.content = String(data.content);
}
// 确保消息内容是字符串类型
if (data.content && typeof data.content !== "string") {
data.content = String(data.content);
}
// 直接拼接内容到AI消息
if (data.content) {
if (chatMsgList.value[aiMsgIndex].isLoading) {
// 直接拼接内容到AI消息
if (data.content) {
if (chatMsgList.value[aiMsgIndex].isLoading) {
chatMsgList.value[aiMsgIndex].msg = "";
}
chatMsgList.value[aiMsgIndex].msg += data.content;
chatMsgList.value[aiMsgIndex].isLoading = false;
nextTick(() => scrollToBottom());
}
// 处理完成状态
if (data.finish) {
const msg = chatMsgList.value[aiMsgIndex].msg;
if (!msg || chatMsgList.value[aiMsgIndex].isLoading) {
chatMsgList.value[aiMsgIndex].msg = "未获取到内容,请重试";
chatMsgList.value[aiMsgIndex].isLoading = false;
if (data.toolCall) {
chatMsgList.value[aiMsgIndex].msg = "";
}
chatMsgList.value[aiMsgIndex].msg += data.content;
chatMsgList.value[aiMsgIndex].isLoading = false;
nextTick(() => scrollToBottom());
}
// 处理完成状态
if (data.finish) {
const msg = chatMsgList.value[aiMsgIndex].msg;
if (!msg || chatMsgList.value[aiMsgIndex].isLoading) {
chatMsgList.value[aiMsgIndex].msg = "未获取到内容,请重试";
chatMsgList.value[aiMsgIndex].isLoading = false;
if (data.toolCall) {
chatMsgList.value[aiMsgIndex].msg = "";
}
}
// 处理toolCall
if (data.toolCall) {
chatMsgList.value[aiMsgIndex].toolCall = data.toolCall;
}
// 处理question
if (data.question && data.question.length > 0) {
chatMsgList.value[aiMsgIndex].question = data.question;
}
// 重置会话状态
isSessionActive.value = false;
// 处理toolCall
if (data.toolCall) {
chatMsgList.value[aiMsgIndex].toolCall = data.toolCall;
}
};
// 处理question
if (data.question && data.question.length > 0) {
chatMsgList.value[aiMsgIndex].question = data.question;
}
// 重置会话状态
isSessionActive.value = false;
}
};
// 重置消息状态
const resetMessageState = () => {
@@ -551,13 +500,13 @@ const sendMessage = async (message, isInstruct = false) => {
uni.showLoading({
title: "正在连接服务器...",
});
// 尝试重新初始化WebSocket连接
try {
await initWebSocket();
// 等待短暂时间确保连接建立
await new Promise(resolve => setTimeout(resolve, 1000));
// 检查连接是否成功建立
if (!webSocketConnectStatus) {
uni.hideLoading();