Compare commits

..

4 Commits

Author SHA1 Message Date
zoujing
cf17633556 feat: 修复不能渲染的问题 2025-09-10 12:14:59 +08:00
b062ec7522 feat: 朵花的小程序id 2025-09-09 23:39:01 +08:00
35abfea922 feat: 停止的时候处理 2025-09-09 23:13:33 +08:00
6fc01a1bd5 feat: 意见反馈 2025-09-09 23:12:39 +08:00
5 changed files with 165 additions and 147 deletions

View File

@ -57,7 +57,7 @@
"quickapp" : {},
/* */
"mp-weixin" : {
"appid": "wx5e79df5996572539",
"appid" : "wx23f86d809ae80259",
"setting" : {
"urlCheck" : false
},

View File

@ -97,12 +97,12 @@
/>
<ActivityListComponent
v-if="mainPageDataModel.activityList.length > 0"
v-if="mainPageDataModel.activityList && mainPageDataModel.activityList.length > 0"
:activityList="mainPageDataModel.activityList"
/>
<RecommendPostsComponent
v-if="mainPageDataModel.recommendTheme.length > 0"
v-if="mainPageDataModel.recommendTheme && mainPageDataModel.recommendTheme.length > 0"
:recommendThemeList="mainPageDataModel.recommendTheme"
/>
</ChatCardOther>
@ -256,8 +256,9 @@ const handleScrollToLower = () => {};
// -
const scrollToBottom = () => {
nextTick(() => {
// 使
scrollTop.value = 99999;
//
// DOM
setTimeout(() => {
scrollTop.value = scrollTop.value + Math.random();
}, 10);
@ -353,15 +354,6 @@ onMounted(async () => {
addNoticeListener();
initTypewriterManager();
initWebSocket();
uni.getProvider({
service: "oauth",
success: (res) => {
console.log("getProvider success", res);
},
fail: (err) => {
console.log("getProvider fail", err);
},
});
} catch (error) {
console.error("页面初始化错误:", error);
}
@ -393,9 +385,9 @@ const getMainPageData = async () => {
const sceneId = appStore.sceneId || "";
const res = await mainPageData(sceneId);
if (res.code === 0) {
initData();
mainPageDataModel.value = res.data;
agentId.value = res.data.agentId;
initData();
setTimeoutScrollToBottom();
}
};
@ -538,7 +530,6 @@ const initTypewriterManager = () => {
typewriterManager.setCallbacks({
//
onCharacterTyped: (displayedContent) => {
//
scrollToBottom();
},
//
@ -671,14 +662,14 @@ const stopRequest = () => {
// (messageType=2)
sendWebSocketMessage(2, "stop_request", { silent: true });
//
//
if (typewriterManager) {
typewriterManager.stopTypewriter();
}
//
const currentStatus = typewriterManager.getStatus();
const currentDisplayedContent = currentStatus.displayedContent;
//
isSessionActive.value = false;
resetMessageState();
// 使
typewriterManager.stopAndKeepCurrent();
// AI
const aiMsgIndex = chatMsgList.value.length - 1;
@ -687,13 +678,21 @@ const stopRequest = () => {
chatMsgList.value[aiMsgIndex].msgType === MessageRole.AI
) {
chatMsgList.value[aiMsgIndex].isLoading = false;
// 使
if (
!chatMsgList.value[aiMsgIndex].msg ||
chatMsgList.value[aiMsgIndex].msg.startsWith("加载中")
currentDisplayedContent &&
currentDisplayedContent.trim() &&
!currentDisplayedContent.startsWith("加载中")
) {
chatMsgList.value[aiMsgIndex].msg = currentDisplayedContent;
} else {
chatMsgList.value[aiMsgIndex].msg = "请求已停止";
}
}
}
//
isSessionActive.value = false;
console.log("请求已停止,状态已重置");

View File

@ -60,7 +60,7 @@ const initData = () => {
icon: "/static/quick/quick_icon_call.png",
title: "反馈意见",
content: "有意见告诉朵朵",
type: "Command.createWorkOrder",
type: "Command.feedbackCard",
},
];
};

View File

@ -1,5 +1,5 @@
{
"appid": "wx5e79df5996572539",
"appid": "wx23f86d809ae80259",
"compileType": "miniprogram",
"libVersion": "3.8.10",
"packOptions": {

View File

@ -7,8 +7,8 @@ class TypewriterManager {
// 配置选项
this.options = {
typingSpeed: 50, // 打字速度(毫秒)
cursorText: '', // 光标样式
...options
cursorText: "", // 光标样式
...options,
};
// 状态变量
@ -41,7 +41,7 @@ class TypewriterManager {
* @param {string} content - 要添加的内容
*/
addContent(content) {
if (typeof content !== 'string') {
if (typeof content !== "string") {
content = String(content);
}
this.currentMessageContent += content;
@ -70,9 +70,13 @@ class TypewriterManager {
_typeNextChar() {
// 如果已显示内容长度小于完整内容长度,继续打字
if (this.displayedContent.length < this.currentMessageContent.length) {
const nextLength = Math.min(
this.displayedContent.length + 1,
this.currentMessageContent.length
);
this.displayedContent = this.currentMessageContent.substring(
0,
this.displayedContent.length + 1
nextLength
);
const displayContent = this.displayedContent;
@ -92,7 +96,6 @@ class TypewriterManager {
this.typewriterTimer = setTimeout(() => {
this._typeNextChar();
}, delay);
} else {
// 打字完成,移除光标
if (this.onContentUpdate) {
@ -119,6 +122,21 @@ class TypewriterManager {
this.isTyping = false;
}
/**
* 停止打字机效果并保留当前显示的内容
* 与stopTypewriter不同这个方法会将当前显示的内容设为最终内容
*/
stopAndKeepCurrent() {
this.stopTypewriter();
// 将当前显示的内容设为完整内容,避免后续添加更多内容
this.currentMessageContent = this.displayedContent;
// 调用完成回调
if (this.onTypingComplete) {
this.onTypingComplete(this.displayedContent);
}
}
/**
* 重置打字机状态
*/
@ -137,9 +155,10 @@ class TypewriterManager {
isTyping: this.isTyping,
currentContent: this.currentMessageContent,
displayedContent: this.displayedContent,
progress: this.currentMessageContent.length > 0
progress:
this.currentMessageContent.length > 0
? this.displayedContent.length / this.currentMessageContent.length
: 0
: 0,
};
}