From 86429684c46f4c5ad8250f8d9bb6031f015c3965 Mon Sep 17 00:00:00 2001
From: no99 <17663930442@163.com>
Date: Mon, 25 Aug 2025 16:06:54 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A4=BA=E5=AE=9D=E5=A5=87=E5=85=B5=E5=A4=A7?=
=?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=BB=9A=E5=8A=A8=E5=88=B0=E9=A1=B6=E9=83=A8?=
=?UTF-8?q?=EF=BC=8C=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E9=BB=98=E8=AE=A4?=
=?UTF-8?q?=E5=9B=BE=E7=89=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/store/chat.js | 2 +-
src/views/AIchat.vue | 74 +++++++++++++++++++++++++++++++++-
src/views/components/HistoryRecord.vue | 38 ++++++++++++-----
src/views/homePage.vue | 11 +++++
4 files changed, 113 insertions(+), 12 deletions(-)
diff --git a/src/store/chat.js b/src/store/chat.js
index 99a1489..8d7c63b 100644
--- a/src/store/chat.js
+++ b/src/store/chat.js
@@ -17,7 +17,7 @@ export const useChatStore = defineStore("chat", {
chatInput:false,
emotionInput:false,
firstAPICall:false,
-
+ dbqbScrollToTop:true,
}),
actions: {
async getUserCount() {
diff --git a/src/views/AIchat.vue b/src/views/AIchat.vue
index e532796..d854503 100644
--- a/src/views/AIchat.vue
+++ b/src/views/AIchat.vue
@@ -1202,7 +1202,6 @@ watch(
if (result.code == 406) {
AIcontent.value = `
尊敬的用户,目前您的token余额为0,系统将无法处理您的搜索请求,您可以补充token后再进行搜索。token兑换的入口在右上角“获取token次数”,点击即可操作哦~
`;
-
}
const aiMsg = {
@@ -4461,6 +4460,10 @@ watch(
{ immediate: true } // 添加immediate属性,确保初始化时执行一次
);
+const scrollToTop = () => {
+ chatStore.dbqbScrollToTop = !chatStore.dbqbScrollToTop;
+};
+
// 添加渲染所有K线图的方法
function renderAllKlineCharts() {
console.log("重新渲染所有K线图");
@@ -4767,6 +4770,24 @@ onUnmounted(() => {
+
+
diff --git a/src/views/components/HistoryRecord.vue b/src/views/components/HistoryRecord.vue
index 3251da3..559b109 100644
--- a/src/views/components/HistoryRecord.vue
+++ b/src/views/components/HistoryRecord.vue
@@ -92,6 +92,7 @@
@@ -463,15 +464,21 @@ const getHistoryList = async (params) => {
try {
const result = await getHistoryListAPI(params);
historyRecords.value = result.data;
-
+
// 检查数据是否有变化,使用简单的哈希值比较
- const currentDataHash = JSON.stringify(result.data.map(r => ({ id: r.id, isTop: r.isTop, createdTime: r.createdTime })));
+ const currentDataHash = JSON.stringify(
+ result.data.map((r) => ({
+ id: r.id,
+ isTop: r.isTop,
+ createdTime: r.createdTime,
+ }))
+ );
if (cachedCategoryHistory && lastDataHash === currentDataHash) {
// 使用缓存的分类结果
categoryHistory.value = cachedCategoryHistory;
return;
}
-
+
let remainingRecords = result.data; // 复制原数组
// console.log(
// "params",
@@ -520,25 +527,28 @@ const getHistoryList = async (params) => {
const yesterday = moment().subtract(1, "days").endOf("day");
const sevenDaysAgo = moment().subtract(7, "days").startOf("day");
const thirtyDaysAgo = moment().subtract(30, "days").startOf("day");
-
+
const topList = [];
const todayList = [];
const recent3DaysList = [];
const recent7DaysList = [];
const recent30DaysList = [];
-
+
remainingRecords.forEach((record) => {
if (record.isTop === 1) {
topList.push(record);
return;
}
-
+
const recordDate = moment(record.createdTime);
const recordDateStr = recordDate.format("YYYY-MM-DD");
-
+
if (recordDateStr === today) {
todayList.push(record);
- } else if (recordDate.isAfter(threeDaysAgo) && recordDate.isBefore(yesterday)) {
+ } else if (
+ recordDate.isAfter(threeDaysAgo) &&
+ recordDate.isBefore(yesterday)
+ ) {
recent3DaysList.push(record);
} else if (recordDate.isAfter(sevenDaysAgo)) {
recent7DaysList.push(record);
@@ -571,11 +581,11 @@ const getHistoryList = async (params) => {
list: recent30DaysList,
},
];
-
+
// 更新缓存
cachedCategoryHistory = categoryHistory.value;
lastDataHash = currentDataHash;
-
+
// console.log("historyRecords", historyRecords.value);
// console.log("categoryHistory", categoryHistory.value);
} catch (e) {
@@ -655,6 +665,14 @@ const closeHistory = () => {
}
};
+// 图片加载错误处理
+const handleImageError = (event) => {
+ console.error("图片加载失败:", event.target.src);
+ // 可以设置默认图片或重试逻辑
+ event.target.src =
+ "https://d31zlh4on95l9h.cloudfront.net/images/9a431843b182c64a05fa3c8f6772b8a4.png";
+};
+
const historyData = ref({});
const selectRecord = async (record) => {
if (props.currentType == "AIchat" && chatStore.firstAPICall) {
diff --git a/src/views/homePage.vue b/src/views/homePage.vue
index e5753d6..807da2e 100644
--- a/src/views/homePage.vue
+++ b/src/views/homePage.vue
@@ -619,6 +619,17 @@ watch(
);
watch(
+ () => chatStore.dbqbScrollToTop,
+ async (newValue, oldValue) => {
+ const container = getCurrentScrollContainer();
+ if (!container) return;
+
+ await nextTick(); // 确保在DOM更新后执行
+ container.scrollTop = 0;
+ }
+);
+
+watch(
activeTab,
async () => {
console.log("activeTab变化了", activeTab.value);