feat(历史记录): 重构历史记录页面并添加AI咨询功能

This commit is contained in:
yangzhe 2025-12-17 09:14:21 +08:00
parent 8be8799e3d
commit df1649e7c5
3 changed files with 92 additions and 26 deletions

View File

@ -46,12 +46,16 @@
<view class="history-list">
<view
class="date-group"
v-for="group in groupedHistoryList"
:key="group.header"
v-for="(group, groupIndex) in currentHistoryList"
:key="groupIndex"
>
<view class="date-header">{{ group.header }}</view>
<view class="date-header">{{ group.id }}</view>
<view class="history-item" v-for="item in group.items" :key="item.id">
<view
class="history-item"
v-for="item in group.conversation"
:key="item.id"
>
<!-- 批量删除模式下的选择框 -->
<view
class="item-checkbox"
@ -72,11 +76,14 @@
<view class="item-content">
<view class="item-header">
<view class="item-icon">
<text class="icon-text">B</text>
<image
class="icon-image"
src="/static/common/images/icon_chat2.png"
/>
</view>
<view class="item-title">{{ item.title }}</view>
</view>
<view class="item-description">{{ item.content }}</view>
<!-- <view class="item-description">{{ item.content }}</view> -->
</view>
</view>
</view>
@ -178,9 +185,20 @@ export default {
type: "human",
},
],
chatHistoryAI: [], // ai
chatHistoryTeacher: [], //
};
},
computed: {
// tab
currentHistoryList() {
if (this.activeTab === "1") {
return this.chatHistoryAI;
} else {
return this.chatHistoryTeacher;
}
},
// tab
filteredHistoryList() {
return this.historyList.filter((item) => {
@ -220,7 +238,58 @@ export default {
return groups;
},
},
onLoad() {
this.getChatHistoryList();
// this.GetDialogueList_User();
},
methods: {
// ai
async getChatHistoryList() {
this.$u.api.GetConversationPage().then((res) => {
this.chatHistoryAI = res.data;
// if (this.chatHistoryAI.length > 0) {
// this.chatHistoryAI = res.data.map((group) => {
// // conversation
// return {
// ...group,
// conversation: group.conversation.sort((a, b) => {
// //
// return (
// new Date(b.startTime).getTime() -
// new Date(a.startTime).getTime()
// );
// }),
// };
// });
// }
console.log("this.chatHistoryAI", this.chatHistoryAI);
});
},
//
async GetDialogueList_User() {
this.$u.api.GetDialogueList_UserApi().then((res) => {
this.chatHistoryTeacher = res.data;
// if (this.chatHistoryTeacher.length > 0) {
// this.chatHistoryTeacher = res.data.map((group) => {
// // conversation
// return {
// ...group,
// conversation: group.conversation.sort((a, b) => {
// //
// return (
// new Date(b.startTime).getTime() -
// new Date(a.startTime).getTime()
// );
// }),
// };
// });
// }
});
},
//
formatTime(timestamp) {
const now = new Date();
@ -277,6 +346,12 @@ export default {
switchTab(tab) {
this.activeTab = tab;
// tabtab
if (tab === "1") {
this.getChatHistoryList();
} else {
this.GetDialogueList_User();
}
},
// /
@ -348,6 +423,10 @@ export default {
(item) => !this.selectedItems.includes(item.id)
);
console.log('删除后的历史记录:',this.historyList);
return
//
this.selectedItems = [];
this.selectAll = false;
@ -358,18 +437,6 @@ export default {
type: "success",
});
},
handleDelete(item, callback) {
console.log("handleDelete", item);
setTimeout(() => {
this.$refs.uToast.show({
title: "撤回成功",
type: "success",
});
callback(true);
}, 1500);
},
},
};
</script>
@ -543,22 +610,21 @@ export default {
.item-header {
display: flex;
align-items: center;
margin-bottom: 24rpx;
margin-bottom: 30rpx;
.item-icon {
width: 48rpx;
height: 48rpx;
background-color: #4f6aff;
width: 50rpx;
height: 50rpx;
background-color: rgba(79, 106, 255, 0.1);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 16rpx;
.icon-text {
color: #ffffff;
font-size: 24rpx;
font-weight: bold;
.icon-image {
width: 26rpx;
height: 26rpx;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB