fix: 思考内容正确显示 - 判断thinking字段存在而非值

This commit is contained in:
2026-04-26 21:33:01 +08:00
parent ac5335ac4f
commit c6bdfb15cc
2 changed files with 7 additions and 6 deletions

View File

@@ -1165,9 +1165,10 @@ function renderMessages() {
// 思考内容块仅AI消息
let thinkingHtml = '';
if (!isUser && msg.thinking) {
// 判断是否是当前正在生成的消息有thinking且content为空或很短
if (!isUser && 'thinking' in msg) {
// 判断是否是当前正在生成的消息有thinking字段且正在加载
const isGenerating = index === currentConversation.messages.length - 1 && isLoading && enableThinking;
// 思考进行中且没有正式内容时展开
const expandedClass = isGenerating && !msg.content ? 'expanded' : '';
thinkingHtml = `
@@ -1177,7 +1178,7 @@ function renderMessages() {
<span>思考过程</span>
<svg class="thinking-arrow" viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M7 10l5 5 5-5z"/></svg>
</div>
<div class="thinking-content">${renderMarkdown(msg.thinking)}</div>
<div class="thinking-content">${renderMarkdown(msg.thinking || '思考中...')}</div>
</div>`;
}

View File

@@ -8,12 +8,12 @@
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>AI助手</title>
<link rel="stylesheet" href="style.css?v=2.7.2">
<link rel="stylesheet" href="style.css?v=2.7.3">
<link rel="manifest" href="manifest.json">
</head>
<body>
<div id="app"></div>
<script src="marked.min.js?v=2.7.2"></script>
<script src="app.js?v=2.7.2"></script>
<script src="marked.min.js?v=2.7.3"></script>
<script src="app.js?v=2.7.3"></script>
</body>
</html>