Browse Source

显示历史对话

ds_hxl
宋杰 3 weeks ago
parent
commit
15350ba4c6
  1. 17
      src/views/AiEmotion.vue

17
src/views/AiEmotion.vue

@ -142,6 +142,19 @@ const isPageLoaded = ref(false); // 控制页面是否显示
const isRotating = ref(false);// const isRotating = ref(false);//
const userInputDisplayRef = ref(null);// const userInputDisplayRef = ref(null);//
//
const loadMessagesFromLocalStorage = () => {
const storedMessages = localStorage.getItem('chatMessages');
if (storedMessages) {
messages.value = JSON.parse(storedMessages);
}
};
//
const saveMessagesToLocalStorage = () => {
localStorage.setItem('chatMessages', JSON.stringify(messages.value));
};
// //
function startImageRotation() { function startImageRotation() {
isRotating.value = true; isRotating.value = true;
@ -239,6 +252,9 @@ async function sendMessage() {
} finally { } finally {
// //
isRotating.value = false; isRotating.value = false;
//
saveMessagesToLocalStorage();
} }
} else { } else {
messages.value.push({ messages.value.push({
@ -400,6 +416,7 @@ function renderCharts(data) {
// //
onMounted(() => { onMounted(() => {
startImageRotation(); startImageRotation();
loadMessagesFromLocalStorage();//
}); });
</script> </script>

Loading…
Cancel
Save