Compare commits

..

No commits in common. "f549b084a8d985d3dca6baaf3497a9df04a5c003" and "bd08d3a988f9eae52ee40b786a80387858f2bbb4" have entirely different histories.

5 changed files with 55 additions and 78 deletions

View File

@ -250,29 +250,38 @@ const chatMessages = ref([
// DeepSeek API
const sendMessage = async () => {
if (!userInput.value.trim() || isLoading.value) return;
if (!userInput.value.trim() || isLoading.value) return
//
const userMessage = userInput.value.trim();
chatMessages.value.push({ role: 'user', content: userMessage });
userInput.value = '';
const userMessage = userInput.value.trim()
chatMessages.value.push({ role: 'user', content: userMessage })
userInput.value = ''
//
await nextTick();
scrollToBottom();
//
await nextTick()
if (chatMessagesRef.value) {
chatMessagesRef.value.scrollTop = chatMessagesRef.value.scrollHeight
}
//
isLoading.value = true;
chatMessages.value.push({ role: 'assistant', content: '思考中...' });
const aiMessageIndex = chatMessages.value.length - 1;
//
isLoading.value = true
try {
// 5
const apiMessages = chatMessages.value
.slice(-5)
.map(msg => ({ role: msg.role, content: msg.content }));
// DeepSeek API
const apiMessages = [
{ role: 'system', content: '' }
]
// API
// 10()
const recentMessages = chatMessages.value.slice(-10)
recentMessages.forEach(msg => {
apiMessages.push({
role: msg.role === 'assistant' ? 'assistant' : 'user',
content: msg.content
})
})
// DeepSeek API
const response = await fetch('https://api.deepseek.com/chat/completions', {
method: 'POST',
headers: {
@ -282,59 +291,36 @@ const sendMessage = async () => {
body: JSON.stringify({
model: 'deepseek-chat',
messages: apiMessages,
stream: true //
stream: false
})
});
})
if (!response.ok) {
throw new Error(`API错误: ${response.status}`);
throw new Error('API请求失败')
}
//
const reader = response.body.getReader();
let fullResponse = '';
const decoder = new TextDecoder();
const data = await response.json()
const aiResponse = data.choices && data.choices[0]?.message?.content || '抱歉,我无法回答这个问题。'
while (true) {
const { done, value } = await reader.read();
if (done) break;
const aiResponseHtml = md.render(aiResponse)
// APIndjson
const chunk = decoder.decode(value);
const lines = chunk.split('\n').filter(line => line.trim());
for (const line of lines) {
try {
const data = JSON.parse(line.replace('data: ', ''));
if (data.choices?.[0]?.delta?.content) {
fullResponse += data.choices[0].delta.content;
// UI
chatMessages.value[aiMessageIndex].content = md.render(fullResponse);
scrollToBottom();
}
} catch (e) {
console.warn('解析流数据失败:', e);
}
}
}
// AI
chatMessages.value.push({ role: 'assistant', content: aiResponseHtml })
} catch (error) {
console.error('请求失败:', error);
chatMessages.value[aiMessageIndex].content = '抱歉,回答时遇到问题,请重试。';
console.error('DeepSeek API调用失败:', error)
chatMessages.value.push({ role: 'assistant', content: '抱歉,我遇到了技术问题,请稍后再试。' })
} finally {
isLoading.value = false;
scrollToBottom();
}
};
isLoading.value = false
//
const scrollToBottom = () => {
nextTick().then(() => {
//
await nextTick()
if (chatMessagesRef.value) {
chatMessagesRef.value.scrollTop = chatMessagesRef.value.scrollHeight;
chatMessagesRef.value.scrollTop = chatMessagesRef.value.scrollHeight
}
});
};
}
}
//
const fundingLegendStatus = ref([true, true, true])

View File

@ -59,7 +59,7 @@
<div class="lab-info">
<div class="info-item">
<span class="info-label">中心名称:</span>
<span class="info-label">研究中心名称:</span>
<span class="info-value">{{ lab.basicInformation.name2 }}</span>
</div>
<div class="info-item">

View File

@ -16,7 +16,7 @@
<span class="display-text">{{ labData.basicInformation.name1 }}</span>
</div>
<div class="form-item">
<span class="label">中心名称:</span>
<span class="label">工程研究中心名称:</span>
<span class="display-text">{{ labData.basicInformation.name2 }}</span>
</div>
</div>

View File

@ -83,7 +83,7 @@
</div>
<div class="info-row">
<span class="info-label">职称 / 职务:</span>
<span class="info-value">{{ teacher.basicInformation.name2 }}{{ teacher.basicInformation.name3 ? ' / ' + teacher.basicInformation.name3 : '' }}</span>
<span class="info-value">{{ teacher.basicInformation.name2 }} / {{ teacher.basicInformation.name3 }}</span>
</div>
<div class="info-row">
<span class="info-label">所属院校:</span>
@ -398,11 +398,6 @@ const openTeacherDetail = (teacher) => {
<style scoped>
.teacher-info span{
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 100%;
display: block;
}
.evaluation-page {
position: absolute;

View File

@ -206,10 +206,6 @@ h2{
.info-value {
font-weight: bold;
/* white-space: nowrap; */
text-overflow: ellipsis;
overflow: hidden;
font-size: 12px;
}
/* ========= 按钮样式 ========= */