|
|
|
@ -149,8 +149,6 @@
|
|
|
|
|
|
|
|
|
|
#answerArea {
|
|
|
|
|
min-height: 240px;
|
|
|
|
|
max-height: 500px; /* 设置最大高度 */
|
|
|
|
|
overflow-y: auto; /* 添加垂直滚动条 */
|
|
|
|
|
height: auto;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
}
|
|
|
|
@ -209,7 +207,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
<button id="submitBtn" onclick="submitQuestion()"><span class="icon">💡</span>提问</button>
|
|
|
|
|
<button id="clearBtn" onclick="clearAll()"><span class="icon">🗑️</span>清空</button>
|
|
|
|
|
<button id="relationBtn" onclick="generateRelation()" style="background-color:#9c27b0"><span class="icon">👥</span>生成刘帮集团的人物关系图</button>
|
|
|
|
|
<button id="relationBtn" onclick="generateRelation()" style="background-color:#9c27b0"><span class="icon">👥</span>生成刘帮集团的人物关系图
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
@ -346,8 +345,8 @@
|
|
|
|
|
document.getElementById('answerArea').innerHTML = '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 在script部分添加新函数
|
|
|
|
|
function generateRelation() {
|
|
|
|
|
// 在script部分添加新函数
|
|
|
|
|
function generateRelation() {
|
|
|
|
|
const answerArea = document.getElementById('answerArea');
|
|
|
|
|
answerArea.innerHTML = '<div class="loading-animation"><div class="spinner"></div><div>正在生成人物关系图...</div></div>';
|
|
|
|
|
|
|
|
|
@ -372,18 +371,7 @@ function generateRelation() {
|
|
|
|
|
|
|
|
|
|
function processChunk() {
|
|
|
|
|
return reader.read().then(({done, value}) => {
|
|
|
|
|
if (done) {
|
|
|
|
|
// 在HTML内容完全接收后执行其中的脚本
|
|
|
|
|
const scripts = answerArea.getElementsByTagName('script');
|
|
|
|
|
for (let i = 0; i < scripts.length; i++) {
|
|
|
|
|
try {
|
|
|
|
|
eval(scripts[i].innerHTML);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('脚本执行错误:', e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (done) return;
|
|
|
|
|
|
|
|
|
|
buffer += decoder.decode(value, {stream: true});
|
|
|
|
|
const lines = buffer.split('\n');
|
|
|
|
@ -399,7 +387,6 @@ function generateRelation() {
|
|
|
|
|
accumulatedContent += data.reply;
|
|
|
|
|
answerArea.innerHTML = marked.parse(accumulatedContent, markedOptions);
|
|
|
|
|
MathJax.typesetPromise();
|
|
|
|
|
answerArea.scrollTop = answerArea.scrollHeight;
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log('忽略解析错误:', e);
|
|
|
|
@ -407,15 +394,25 @@ function generateRelation() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return processChunk();
|
|
|
|
|
|
|
|
|
|
return processChunk().then(() => {
|
|
|
|
|
// 在流处理完成后保存完整的markdown内容
|
|
|
|
|
localStorage.setItem('lastMarkdownContent', accumulatedContent);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return processChunk();
|
|
|
|
|
})
|
|
|
|
|
.catch(error => {
|
|
|
|
|
answerArea.innerHTML = '<div style="color:red">生成关系图出错,请重试</div>';
|
|
|
|
|
// 移除加载动画
|
|
|
|
|
answerArea.innerHTML = '';
|
|
|
|
|
|
|
|
|
|
console.error('Error:', error);
|
|
|
|
|
// 出错时也移除加载动画
|
|
|
|
|
answerArea.innerHTML = '<div style="color:red">请求出错,请重试</div>';
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
<script src="/static/mathjax/es5/tex-mml-chtml.js" id="MathJax-script" async></script>
|
|
|
|
|
<script src="/static/js/marked.min.js"></script>
|
|
|
|
|