可信代码库-AI大模型对话历史分页及搜索功能对接
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
></d-search>
|
></d-search>
|
||||||
<div class="mt-3 px-20">
|
<div class="mt-3 px-20">
|
||||||
<d-table
|
<d-table
|
||||||
|
v-if="currentDhlsData.length>0"
|
||||||
class="jyh-table"
|
class="jyh-table"
|
||||||
:data="currentDhlsData"
|
:data="currentDhlsData"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</d-column>
|
</d-column>
|
||||||
</d-table>
|
</d-table>
|
||||||
|
<NoData v-else :small="false"></NoData>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-20 mb-20 flex justify-end">
|
<div class="mt-20 mb-20 flex justify-end">
|
||||||
<d-pagination
|
<d-pagination
|
||||||
@@ -56,6 +58,7 @@
|
|||||||
></d-search>
|
></d-search>
|
||||||
<div class="mt-3 px-20">
|
<div class="mt-3 px-20">
|
||||||
<d-table
|
<d-table
|
||||||
|
v-if="currentCollectionData.length>0"
|
||||||
class="jyh-table"
|
class="jyh-table"
|
||||||
:data="currentCollectionData"
|
:data="currentCollectionData"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
@@ -76,6 +79,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</d-column>
|
</d-column>
|
||||||
</d-table>
|
</d-table>
|
||||||
|
<NoData v-else :small="false"></NoData>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-20 mb-20 flex justify-end">
|
<div class="mt-20 mb-20 flex justify-end">
|
||||||
<d-pagination
|
<d-pagination
|
||||||
@@ -111,6 +115,7 @@
|
|||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Message } from 'vue-devui/message';
|
import { Message } from 'vue-devui/message';
|
||||||
|
import NoData from '@/components/NoData/NoData.vue';
|
||||||
|
|
||||||
// 接收父组件传递的用户名
|
// 接收父组件传递的用户名
|
||||||
const props = defineProps(['username']);
|
const props = defineProps(['username']);
|
||||||
@@ -154,9 +159,14 @@ const getQuestionHistory = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(
|
const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', {
|
||||||
`${import.meta.env.VITE_AI_API_HOST}/api/conversationList?userId=${props.username}&list_type=history`
|
"userId": props.username,
|
||||||
);
|
"list_type": "history",
|
||||||
|
"is_manage": true,
|
||||||
|
"page": currentPage.value,
|
||||||
|
"size": pageSize.value,
|
||||||
|
"search": searchText.value
|
||||||
|
});
|
||||||
if (data.conversationList) {
|
if (data.conversationList) {
|
||||||
dhlsList.value = data.conversationList
|
dhlsList.value = data.conversationList
|
||||||
}
|
}
|
||||||
@@ -172,9 +182,14 @@ const getQuestionCollection = async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(
|
const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', {
|
||||||
`${import.meta.env.VITE_AI_API_HOST}/api/conversationList?userId=${props.username}&list_type=collection`
|
"userId": props.username,
|
||||||
);
|
"list_type": "collection",
|
||||||
|
"is_manage": true,
|
||||||
|
"page": currentPage.value,
|
||||||
|
"size": pageSize.value,
|
||||||
|
"search": searchText.value
|
||||||
|
});
|
||||||
if (data.conversationList) {
|
if (data.conversationList) {
|
||||||
collectionList.value = data.conversationList
|
collectionList.value = data.conversationList
|
||||||
}
|
}
|
||||||
@@ -186,27 +201,65 @@ const getQuestionCollection = async () => {
|
|||||||
// 打开模态框时加载数据
|
// 打开模态框时加载数据
|
||||||
const openModal = async () => {
|
const openModal = async () => {
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
await getQuestionHistory();
|
await fetchData(); // 调用接口
|
||||||
await getQuestionCollection();
|
|
||||||
currentPage.value = 1; // 重置页码
|
currentPage.value = 1; // 重置页码
|
||||||
};
|
};
|
||||||
|
|
||||||
// 搜索处理
|
// 搜索时触发数据加载
|
||||||
const handleSearch = () => {
|
const handleSearch = async () => {
|
||||||
currentPage.value = 1; // 搜索后重置到第一页
|
currentPage.value = 1; // 搜索后重置到第一页
|
||||||
|
await fetchData(); // 调用接口
|
||||||
};
|
};
|
||||||
|
|
||||||
// 分页大小变化
|
// 分页大小变化时触发数据加载
|
||||||
const handlePageSizeChange = (size) => {
|
const handlePageSizeChange = async (size) => {
|
||||||
pageSize.value = size;
|
pageSize.value = size;
|
||||||
currentPage.value = 1;
|
currentPage.value = 1; // 切换页大小后重置到第一页
|
||||||
|
await fetchData(); // 调用接口
|
||||||
};
|
};
|
||||||
|
|
||||||
// 页码变化
|
// 页码变化时触发数据加载
|
||||||
const handlePageChange = (page) => {
|
const handlePageChange = async (page) => {
|
||||||
currentPage.value = page;
|
currentPage.value = page;
|
||||||
|
await fetchData(); // 调用接口
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 统一数据获取方法
|
||||||
|
const fetchData = async () => {
|
||||||
|
if (!props.username) {
|
||||||
|
Message.error('请先登录');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建公共参数
|
||||||
|
const commonParams = {
|
||||||
|
userId: props.username,
|
||||||
|
is_manage: true,
|
||||||
|
page: currentPage.value,
|
||||||
|
size: pageSize.value,
|
||||||
|
search: searchText.value,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取对话历史
|
||||||
|
const historyData = await axios.post(
|
||||||
|
`${import.meta.env.VITE_AI_API_HOST}/api/conversationList`,
|
||||||
|
{ ...commonParams, list_type: 'history' }
|
||||||
|
);
|
||||||
|
if (historyData.data.conversationList) {
|
||||||
|
dhlsList.value = historyData.data.conversationList;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取收藏对话
|
||||||
|
const collectionData = await axios.post(
|
||||||
|
`${import.meta.env.VITE_AI_API_HOST}/api/conversationList`,
|
||||||
|
{ ...commonParams, list_type: 'collection' }
|
||||||
|
);
|
||||||
|
if (collectionData.data.conversationList) {
|
||||||
|
collectionList.value = collectionData.data.conversationList;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// 选中的行ID
|
// 选中的行ID
|
||||||
const selectedRowKeys = ref([]);
|
const selectedRowKeys = ref([]);
|
||||||
// 复选框选中状态变化
|
// 复选框选中状态变化
|
||||||
@@ -235,8 +288,7 @@ const handleDelete = async (conversationIds, tabType) => {
|
|||||||
);
|
);
|
||||||
if (res.data.code === 20000) {
|
if (res.data.code === 20000) {
|
||||||
Message.success(res.data.message || '删除成功');
|
Message.success(res.data.message || '删除成功');
|
||||||
getQuestionHistory()
|
await fetchData(); // 删除后重新加载数据
|
||||||
getQuestionCollection()
|
|
||||||
selectedRowKeys.value = []; // 清空选中项
|
selectedRowKeys.value = []; // 清空选中项
|
||||||
} else {
|
} else {
|
||||||
Message.error(res.data.message || '删除失败');
|
Message.error(res.data.message || '删除失败');
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<Card class="ViewHistoryAside">
|
<Card class="ViewHistoryAside">
|
||||||
<d-tabs class="jyh-tabs-4" type="wrapped" v-model="selectTab">
|
<d-tabs class="jyh-tabs-4" type="wrapped" v-model="selectTab">
|
||||||
<d-tab id="dhls" title="对话历史">
|
<d-tab id="dhls" title="对话历史">
|
||||||
<d-search icon-position="left" style="width: 100%" placeholder="请输入搜索软件名称" v-model="searchText" @change="handleSearch"></d-search>
|
<d-search icon-position="left" style="width: 100%" placeholder="请输入搜索软件名称" v-model="searchText" @change="loadData"></d-search>
|
||||||
<!-- 可滚动内容区域 -->
|
<!-- 可滚动内容区域 -->
|
||||||
<div class="scrollable-content">
|
<div class="scrollable-content">
|
||||||
<d-collapse class="jyh-collapse" v-model="collapseValue">
|
<d-collapse class="jyh-collapse" v-model="collapseValue">
|
||||||
@@ -101,11 +101,12 @@
|
|||||||
style="width: 60px"
|
style="width: 60px"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="jyh-select"
|
class="jyh-select"
|
||||||
|
@value-change="handleHistoryLimitChange"
|
||||||
>
|
>
|
||||||
<d-option value="10">10</d-option>
|
<d-option value="10">10</d-option>
|
||||||
<d-option value="20">20</d-option>
|
<d-option value="20">20</d-option>
|
||||||
<d-option value="30">30</d-option>
|
<d-option value="30">30</d-option>
|
||||||
<d-option value="0">0</d-option>
|
<d-option value="0">不限</d-option>
|
||||||
</d-select>
|
</d-select>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-right">
|
<div class="control-right">
|
||||||
@@ -120,7 +121,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</d-tab>
|
</d-tab>
|
||||||
<d-tab id="scdh" title="收藏对话">
|
<d-tab id="scdh" title="收藏对话">
|
||||||
<d-search icon-position="left" style="width: 100%" placeholder="请输入搜索软件名称" v-model="searchText" @change="handleSearch"></d-search>
|
<d-search icon-position="left" style="width: 100%" placeholder="请输入搜索软件名称" v-model="searchText" @change="loadData"></d-search>
|
||||||
<!-- 可滚动内容区域 -->
|
<!-- 可滚动内容区域 -->
|
||||||
<div class="scrollable-content">
|
<div class="scrollable-content">
|
||||||
<d-collapse class="jyh-collapse" v-model="collapseValue">
|
<d-collapse class="jyh-collapse" v-model="collapseValue">
|
||||||
@@ -222,15 +223,15 @@
|
|||||||
<d-option value="0">0</d-option>
|
<d-option value="0">0</d-option>
|
||||||
</d-select>
|
</d-select>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="control-right">-->
|
<div class="control-right">
|
||||||
<!-- <d-button class="jyh-button2" variant="solid" @click="openBatchManageModal">-->
|
<d-button class="jyh-button2" variant="solid" @click="openBatchManageModal">
|
||||||
<!-- <template #icon>-->
|
<template #icon>
|
||||||
<!-- <d-icon name="icon-property-setting"></d-icon>-->
|
<d-icon name="icon-property-setting"></d-icon>
|
||||||
<!-- </template>-->
|
</template>
|
||||||
<!-- 批量管理-->
|
批量管理
|
||||||
<!-- </d-button>-->
|
</d-button>
|
||||||
<!-- <BatchManageModal ref="BatchManageModalRef"/>-->
|
<BatchManageModal ref="BatchManageModalRef"/>
|
||||||
<!-- </div>-->
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</d-tab>
|
</d-tab>
|
||||||
</d-tabs>
|
</d-tabs>
|
||||||
@@ -260,6 +261,20 @@ const BatchManageModalRef = ref(null);
|
|||||||
|
|
||||||
const { formatTime } = useTimeFormat();
|
const { formatTime } = useTimeFormat();
|
||||||
|
|
||||||
|
// 监听historyLimit变化,更新page.size并重置页码
|
||||||
|
const handleHistoryLimitChange = (val) => {
|
||||||
|
debugger
|
||||||
|
page.value.size = Number(val) || Infinity; // 0转换为Infinity表示不限
|
||||||
|
page.value.pageNum = 1; // 重置为第一页
|
||||||
|
loadData(); // 重新加载数据
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 统一数据加载方法
|
||||||
|
const loadData = async () => {
|
||||||
|
await getQuestionHistory();
|
||||||
|
await getQuestionCollection();
|
||||||
|
};
|
||||||
|
|
||||||
const handleSelect = (item) => {
|
const handleSelect = (item) => {
|
||||||
// 触发父组件事件,传递选中的 convId
|
// 触发父组件事件,传递选中的 convId
|
||||||
@@ -377,11 +392,23 @@ const cardList = ref([
|
|||||||
]);
|
]);
|
||||||
const dhlsList = ref([]);
|
const dhlsList = ref([]);
|
||||||
const collectionList = ref([]);
|
const collectionList = ref([]);
|
||||||
|
const page = ref({
|
||||||
|
pageNum: 1,
|
||||||
|
size: 10
|
||||||
|
});
|
||||||
|
|
||||||
const VITE_AI_API_HOST = import.meta.env.VITE_AI_API_HOST;
|
const VITE_AI_API_HOST = import.meta.env.VITE_AI_API_HOST;
|
||||||
const getQuestionHistory = async () => {
|
const getQuestionHistory = async () => {
|
||||||
if(props.username) {
|
if(props.username) {
|
||||||
const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=history');
|
const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', {
|
||||||
|
"userId": props.username,
|
||||||
|
"list_type": "history",
|
||||||
|
"is_manage": true,
|
||||||
|
"page": page.value.pageNum,
|
||||||
|
"size": page.value.size,
|
||||||
|
"search": searchText.value
|
||||||
|
});
|
||||||
|
|
||||||
if(data.conversationList) {
|
if(data.conversationList) {
|
||||||
dhlsList.value = data.conversationList
|
dhlsList.value = data.conversationList
|
||||||
} else {
|
} else {
|
||||||
@@ -393,7 +420,14 @@ const getQuestionHistory = async () => {
|
|||||||
};
|
};
|
||||||
const getQuestionCollection = async () => {
|
const getQuestionCollection = async () => {
|
||||||
if(props.username) {
|
if(props.username) {
|
||||||
const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=collection');
|
const {data} = await axios.post(VITE_AI_API_HOST + '/api/conversationList', {
|
||||||
|
"userId": props.username,
|
||||||
|
"list_type": "collection",
|
||||||
|
"is_manage": true,
|
||||||
|
"page": page.value.pageNum,
|
||||||
|
"size": page.value.size,
|
||||||
|
"search": searchText.value
|
||||||
|
});
|
||||||
if(data.conversationList) {
|
if(data.conversationList) {
|
||||||
collectionList.value = data.conversationList
|
collectionList.value = data.conversationList
|
||||||
} else {
|
} else {
|
||||||
@@ -421,8 +455,7 @@ const handleDelete = async (conversationIds, tabType) => {
|
|||||||
);
|
);
|
||||||
if (res.data.code === 20000) {
|
if (res.data.code === 20000) {
|
||||||
Message.success(res.data.message || '删除成功');
|
Message.success(res.data.message || '删除成功');
|
||||||
getQuestionHistory()
|
loadData()
|
||||||
getQuestionCollection()
|
|
||||||
} else {
|
} else {
|
||||||
Message.error(res.data.message || '删除失败');
|
Message.error(res.data.message || '删除失败');
|
||||||
}
|
}
|
||||||
@@ -434,8 +467,7 @@ const handleDelete = async (conversationIds, tabType) => {
|
|||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getQuestionHistory()
|
loadData()
|
||||||
getQuestionCollection()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
Reference in New Issue
Block a user