管理端登录报错修复
This commit is contained in:
@@ -971,7 +971,11 @@ public class AiChatServiceImpl implements AiChatService {
|
|||||||
// 只处理answer类型的消息内容
|
// 只处理answer类型的消息内容
|
||||||
if ("answer".equals(messageType) && content != null && !content.trim().isEmpty()) {
|
if ("answer".equals(messageType) && content != null && !content.trim().isEmpty()) {
|
||||||
log.debug("提取增量内容: {}", content);
|
log.debug("提取增量内容: {}", content);
|
||||||
responseBuilder.append(content);
|
// 解析content中的JSON,提取output字段
|
||||||
|
String extractedContent = extractOutputFromContent(content);
|
||||||
|
if (extractedContent != null) {
|
||||||
|
responseBuilder.append(extractedContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,7 +994,11 @@ public class AiChatServiceImpl implements AiChatService {
|
|||||||
// 如果增量方式没有获取到内容,使用完整消息作为备用
|
// 如果增量方式没有获取到内容,使用完整消息作为备用
|
||||||
if (responseBuilder.length() == 0) {
|
if (responseBuilder.length() == 0) {
|
||||||
log.info("使用完整消息内容作为备用: {}", content);
|
log.info("使用完整消息内容作为备用: {}", content);
|
||||||
responseBuilder.append(content);
|
// 解析content中的JSON,提取output字段
|
||||||
|
String extractedContent = extractOutputFromContent(content);
|
||||||
|
if (extractedContent != null) {
|
||||||
|
responseBuilder.append(extractedContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 记录完整消息用于验证
|
// 记录完整消息用于验证
|
||||||
log.debug("完整消息内容: {}", content);
|
log.debug("完整消息内容: {}", content);
|
||||||
@@ -1096,7 +1104,11 @@ public class AiChatServiceImpl implements AiChatService {
|
|||||||
if ("answer".equals(jsonData.getString("type"))) {
|
if ("answer".equals(jsonData.getString("type"))) {
|
||||||
String content = jsonData.getString("content");
|
String content = jsonData.getString("content");
|
||||||
if (content != null && !content.trim().isEmpty()) {
|
if (content != null && !content.trim().isEmpty()) {
|
||||||
lastCompletedContent = content;
|
// 解析content中的JSON,提取output字段
|
||||||
|
String extractedContent = extractOutputFromContent(content);
|
||||||
|
if (extractedContent != null) {
|
||||||
|
lastCompletedContent = extractedContent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1987,6 +1999,27 @@ public class AiChatServiceImpl implements AiChatService {
|
|||||||
return "/v3/chat";
|
return "/v3/chat";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从content字段中提取output内容
|
||||||
|
*/
|
||||||
|
private String extractOutputFromContent(String content) {
|
||||||
|
try {
|
||||||
|
// 尝试解析content为JSON
|
||||||
|
JSONObject contentJson = JSON.parseObject(content);
|
||||||
|
if (contentJson.containsKey("output")) {
|
||||||
|
String output = contentJson.getString("output");
|
||||||
|
log.debug("成功提取output内容: {}", output);
|
||||||
|
return output;
|
||||||
|
} else {
|
||||||
|
log.debug("content中没有output字段,返回原始内容: {}", content);
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.debug("content不是有效JSON,返回原始内容: {}, 错误: {}", content, e.getMessage());
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证Coze请求参数
|
* 验证Coze请求参数
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# 生产环境配置
|
# 生产环境配置
|
||||||
VITE_APP_TITLE=情绪博物馆管理后台
|
VITE_APP_TITLE=情绪博物馆管理后台
|
||||||
# 生产环境需要配置实际的后端服务器地址
|
# 生产环境使用相对路径,通过nginx代理到后端服务
|
||||||
VITE_APP_BASE_API=http://localhost:19089/api
|
VITE_APP_BASE_API=/api
|
||||||
|
|||||||
+7
-3
@@ -14,9 +14,13 @@ if ! command -v npm &> /dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 执行构建(无论dist目录是否存在,都必须构建)
|
# 清理旧的构建文件
|
||||||
echo "📦 开始构建管理后台项目..."
|
echo "🧹 清理旧的构建文件..."
|
||||||
if npm run build; then
|
rm -rf dist
|
||||||
|
|
||||||
|
# 执行构建(使用生产环境配置)
|
||||||
|
echo "📦 开始构建管理后台项目(生产环境)..."
|
||||||
|
if NODE_ENV=production npm run build; then
|
||||||
echo "✅ 管理后台项目构建成功"
|
echo "✅ 管理后台项目构建成功"
|
||||||
else
|
else
|
||||||
echo "❌ 管理后台项目构建失败,请检查代码"
|
echo "❌ 管理后台项目构建失败,请检查代码"
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ export class StompWebSocketService {
|
|||||||
private subscribeToMessages(): void {
|
private subscribeToMessages(): void {
|
||||||
if (!this.client?.connected) return
|
if (!this.client?.connected) return
|
||||||
|
|
||||||
// 订阅用户私有消息
|
// 订阅用户私有消息 - 这是主要的消息接收频道
|
||||||
if (this.userId) {
|
if (this.userId) {
|
||||||
const userQueuePath = `/user/${this.userId}/queue/messages`
|
const userQueuePath = `/user/${this.userId}/queue/messages`
|
||||||
console.log('📨 订阅用户私有队列:', userQueuePath)
|
console.log('📨 订阅用户私有队列:', userQueuePath)
|
||||||
@@ -283,17 +283,18 @@ export class StompWebSocketService {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 订阅广播消息
|
// 订阅广播消息(系统通知等)
|
||||||
this.client.subscribe('/topic/broadcast', (message: IMessage) => {
|
this.client.subscribe('/topic/broadcast', (message: IMessage) => {
|
||||||
this.handleMessage(message)
|
this.handleMessage(message)
|
||||||
})
|
})
|
||||||
|
|
||||||
// 如果有会话ID,订阅会话特定消息
|
// 注释掉会话特定消息订阅,避免重复接收消息
|
||||||
if (this.conversationId) {
|
// 所有消息都通过用户私有队列接收,确保消息不重复
|
||||||
this.client.subscribe(`/topic/conversation/${this.conversationId}`, (message: IMessage) => {
|
// if (this.conversationId) {
|
||||||
this.handleMessage(message)
|
// this.client.subscribe(`/topic/conversation/${this.conversationId}`, (message: IMessage) => {
|
||||||
})
|
// this.handleMessage(message)
|
||||||
}
|
// })
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user