|
|
@ -18,10 +18,10 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<!-- 输入框和发送按钮 --> |
|
|
|
<footer class="input-container fixed-bottom"> |
|
|
|
<!-- <footer class="input-container fixed-bottom"> |
|
|
|
<input type="text" v-model="userInput" placeholder="请输入内容..." class="input-box" /> |
|
|
|
<button @click="sendMessage" class="send-button">发送</button> |
|
|
|
</footer> |
|
|
|
<button @click="handleSendMessage(userInput)" class="send-button">发送</button> |
|
|
|
</footer> --> |
|
|
|
<!-- <div class="input-container fixed-bottom"> |
|
|
|
<input type="text" v-model="userInput" placeholder="请输入内容..." class="input-box" /> |
|
|
|
<button @click="sendMessage" class="send-button">发送</button> |
|
|
@ -116,9 +116,9 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div v-else class="loading"> |
|
|
|
<!-- <div v-else class="loading"> |
|
|
|
<p>数据加载中,请稍候...</p> |
|
|
|
</div> |
|
|
|
</div> --> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script setup> |
|
|
@ -142,6 +142,9 @@ const isPageLoaded = ref(false); // 控制页面是否显示 |
|
|
|
const isRotating = ref(false);//控制旋转 |
|
|
|
const userInputDisplayRef = ref(null);//消息区域的引用 |
|
|
|
|
|
|
|
//导出方法供外部使用 |
|
|
|
defineExpose({handleSendMessage}) |
|
|
|
|
|
|
|
// 从本地存储中加载对话历史的方法 |
|
|
|
const loadMessagesFromLocalStorage = () => { |
|
|
|
const storedMessages = localStorage.getItem('chatMessages'); |
|
|
@ -175,12 +178,12 @@ function updateSpan01() { |
|
|
|
|
|
|
|
|
|
|
|
// 发送消息方法 |
|
|
|
async function sendMessage() { |
|
|
|
console.log('发送内容:', userInput.value); |
|
|
|
async function handleSendMessage(input) { |
|
|
|
console.log('发送内容:', input); |
|
|
|
|
|
|
|
// 检查用户输入内容是否为空 |
|
|
|
if (userInput.value.trim()) { |
|
|
|
const userMessage = reactive({ sender: 'user', text: userInput.value }); |
|
|
|
if (input.trim()) { |
|
|
|
const userMessage = reactive({ sender: 'user', text: input }); |
|
|
|
messages.value.push(userMessage); |
|
|
|
userInput.value = ''; // 清空输入框 |
|
|
|
|
|
|
@ -280,6 +283,7 @@ async function fetchData(code, market) { |
|
|
|
market: 'usa', |
|
|
|
code: 'TSLA', |
|
|
|
language: 'cn', |
|
|
|
version: 2 |
|
|
|
}; |
|
|
|
|
|
|
|
const stockDataResult = await axios.post( |
|
|
|