Compare commits

...

3 Commits

2 changed files with 18 additions and 18 deletions

View File

@@ -587,11 +587,6 @@ function openConversation(id) {
thinkingBtn.addEventListener('click', () => { thinkingBtn.addEventListener('click', () => {
enableThinking = !enableThinking; enableThinking = !enableThinking;
thinkingBtn.classList.toggle('active', enableThinking); thinkingBtn.classList.toggle('active', enableThinking);
// 如果开启深度思考,关闭联网搜索(智谱思考模型不支持联网)
if (enableThinking && enableSearch) {
enableSearch = false;
searchBtn.classList.remove('active');
}
}); });
} }
@@ -599,11 +594,6 @@ function openConversation(id) {
searchBtn.addEventListener('click', () => { searchBtn.addEventListener('click', () => {
enableSearch = !enableSearch; enableSearch = !enableSearch;
searchBtn.classList.toggle('active', enableSearch); searchBtn.classList.toggle('active', enableSearch);
// 如果开启联网搜索,关闭深度思考
if (enableSearch && enableThinking) {
enableThinking = false;
thinkingBtn.classList.remove('active');
}
}); });
} }
@@ -888,12 +878,17 @@ async function streamGenerate(userMsgIndex) {
if (thinkingEl) { if (thinkingEl) {
thinkingEl.innerHTML = renderMarkdown(currentConversation.messages[aiMessageIndex].thinking) + '<span class="streaming-cursor">▌</span>'; thinkingEl.innerHTML = renderMarkdown(currentConversation.messages[aiMessageIndex].thinking) + '<span class="streaming-cursor">▌</span>';
} }
// 确保思考块展开
const thinkingBlock = lastMessageEl.querySelector('.thinking-block');
if (thinkingBlock && !thinkingBlock.classList.contains('expanded')) {
thinkingBlock.classList.add('expanded');
}
scrollToBottom(); scrollToBottom();
} }
// 处理正式回复内容 // 处理正式回复内容
if (delta.content) { if (delta.content) {
// 如果开启深度思考且开始输出正式内容,折叠思考块 // 如果开启深度思考且开始输出正式内容,说明思考完成,立即折叠思考块
if (enableThinking && !thinkingOutputStarted && currentConversation.messages[aiMessageIndex].thinking) { if (enableThinking && !thinkingOutputStarted && currentConversation.messages[aiMessageIndex].thinking) {
thinkingOutputStarted = true; thinkingOutputStarted = true;
// 折叠思考内容 // 折叠思考内容
@@ -949,7 +944,7 @@ async function performSearch(query) {
}, },
body: JSON.stringify({ body: JSON.stringify({
query: query, query: query,
max_results: 5, max_results: 10,
include_raw_content: false include_raw_content: false
}) })
}); });
@@ -1170,15 +1165,20 @@ function renderMessages() {
// 思考内容块仅AI消息 // 思考内容块仅AI消息
let thinkingHtml = ''; let thinkingHtml = '';
if (!isUser && msg.thinking) { if (!isUser && 'thinking' in msg) {
// 判断是否是当前正在生成的消息有thinking字段且正在加载
const isGenerating = index === currentConversation.messages.length - 1 && isLoading && enableThinking;
// 思考进行中且没有正式内容时展开
const expandedClass = isGenerating && !msg.content ? 'expanded' : '';
thinkingHtml = ` thinkingHtml = `
<div class="thinking-block" onclick="toggleThinking(this)"> <div class="thinking-block ${expandedClass}" onclick="toggleThinking(this)">
<div class="thinking-header"> <div class="thinking-header">
<svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg> <svg viewBox="0 0 24 24" width="16" height="16"><path fill="currentColor" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>
<span>思考过程</span> <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> <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>
<div class="thinking-content">${renderMarkdown(msg.thinking)}</div> <div class="thinking-content">${renderMarkdown(msg.thinking || '思考中...')}</div>
</div>`; </div>`;
} }

View File

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