Compare commits

..

No commits in common. "cf17633556a2f525bfa856ec5761acd71ffeae96" and "cf2a3ba19a0d6c36921293fccc76175160d9d419" have entirely different histories.

5 changed files with 150 additions and 168 deletions

View File

@ -1,102 +1,102 @@
{ {
"name" : "YGTianmuCS", "name": "YGTianmuCS",
"appid" : "__UNI__BB03E8A", "appid": "__UNI__BB03E8A",
"description" : "", "description": "",
"versionName" : "1.0.0", "versionName": "1.0.0",
"versionCode" : "100", "versionCode": "100",
"transformPx" : false, "transformPx": false,
/* 5+App */ /* 5+App */
"app-plus" : { "app-plus": {
"usingComponents" : true, "usingComponents": true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
},
"safearea" : {
"bottom" : {
"offset" : "auto" //
}
},
/* */
"modules" : {},
/* */
"distribute" : {
/* android */
"android" : {
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios" : {},
/* SDK */
"sdkConfigs" : {
"oauth" : {}
}
}
}, },
/* */ "safearea": {
"quickapp" : {}, "bottom": {
/* */ "offset": "auto" //
"mp-weixin" : { }
"appid" : "wx23f86d809ae80259",
"setting" : {
"urlCheck" : false
},
"usingComponents" : true,
"requiredPrivateInfos" : [ "getLocation" ],
"permission" : {
"scope.userLocation" : {
"desc" : "用于获取当前所在城市信息"
}
},
"plugins" : {
"WechatSI" : {
"version" : "0.3.6",
"provider" : "wx069ba97219f66d99"
}
},
"__usePrivacyCheck__" : true
}, },
"mp-alipay" : { /* */
"usingComponents" : true "modules": {},
}, /* */
"mp-baidu" : { "distribute": {
"usingComponents" : true /* android */
}, "android": {
"mp-toutiao" : { "permissions": [
"usingComponents" : true, "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"usePrivacyCheck" : true "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
}, "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"uniStatistics" : { "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"enable" : false "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
}, "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"vueVersion" : "3", "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"h5" : { "<uses-permission android:name=\"android.permission.CAMERA\"/>",
"router" : { "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"base" : "./", "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"mode" : "hash" "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
}, "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"devServer" : { "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"https" : false "<uses-feature android:name=\"android.hardware.camera\"/>",
} "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
/* ios */
"ios": {},
/* SDK */
"sdkConfigs": {
"oauth": {}
}
} }
},
/* */
"quickapp": {},
/* */
"mp-weixin": {
"appid": "wx5e79df5996572539",
"setting": {
"urlCheck": false
},
"usingComponents": true,
"requiredPrivateInfos": ["getLocation"],
"permission": {
"scope.userLocation": {
"desc": "用于获取当前所在城市信息"
}
},
"plugins": {
"WechatSI": {
"version": "0.3.6",
"provider": "wx069ba97219f66d99"
}
},
"__usePrivacyCheck__": true
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true,
"usePrivacyCheck": true
},
"uniStatistics": {
"enable": false
},
"vueVersion": "3",
"h5": {
"router": {
"base": "./",
"mode": "hash"
},
"devServer": {
"https": false
}
}
} }

View File

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

View File

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

View File

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

View File

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