|
@@ -58,7 +58,7 @@
|
|
|
:key="index"
|
|
|
class="history-item"
|
|
|
@click="handleHistoryClick(item)">
|
|
|
- {{ item.fileName||item.askContent }}
|
|
|
+ {{ item.fileName||item.askContent||'暂无标题' }}
|
|
|
</div>
|
|
|
<!-- v-if="hasMore" -->
|
|
|
<div
|
|
@@ -92,7 +92,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
+import { ref, onMounted, onUnmounted } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import { useUserStore } from '../stores/user'
|
|
|
import request from '../utils/request' // 确保引入request
|
|
@@ -132,6 +132,13 @@ const getHistoryList = async () => {
|
|
|
// 组件挂载时获取历史记录
|
|
|
onMounted(() => {
|
|
|
getHistoryList()
|
|
|
+ // 添加事件监听器
|
|
|
+ window.addEventListener('updateHistory', getHistoryList)
|
|
|
+})
|
|
|
+
|
|
|
+// 添加组件卸载时的清理
|
|
|
+onUnmounted(() => {
|
|
|
+ window.removeEventListener('updateHistory', getHistoryList)
|
|
|
})
|
|
|
|
|
|
const handleHistoryClick = async (item) => {
|