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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB