可信代码库-AI大模型收藏对话功能开发
This commit is contained in:
@@ -55,9 +55,23 @@
|
||||
<d-tooltip content="分享">
|
||||
<d-icon style="font-size: 14px;margin-right: 2px" @click.stop="handleShare(item)" name="icon-redo-new"></d-icon>
|
||||
</d-tooltip>
|
||||
<d-tooltip content="更多">
|
||||
<d-dropdown style="width: 100px;" align="start">
|
||||
<d-icon style="font-size: 14px;" @click.stop="handleMore(item)" name="icon-more-operate"></d-icon>
|
||||
</d-tooltip>
|
||||
<template #menu>
|
||||
<ul class="list-menu">
|
||||
<li class="menu-item" @click="toggleCollect(item)">
|
||||
<d-icon
|
||||
:name="item.is_collected ? 'icon-star' : 'icon-star-o'"
|
||||
style="font-size: 14px;padding-right: 4px"
|
||||
/>
|
||||
{{ item.is_collected ? '取消收藏' : '加入收藏' }}
|
||||
</li>
|
||||
<li class="menu-item" @click="handleDelete(item)">
|
||||
<d-icon name="icon-delete" style="font-size: 14px;padding-right: 4px" />删除
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</d-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
@@ -76,35 +90,6 @@
|
||||
<NoData v-else :small="false"></NoData>
|
||||
</div>
|
||||
</d-collapse-item>
|
||||
<!-- <d-collapse-item name="yestoday">-->
|
||||
<!-- <template #title>-->
|
||||
<!-- <div class="jyh-collapse-title">-->
|
||||
<!-- <d-icon style="margin-right: 4px" name="icon-delay"></d-icon>昨天-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<!-- <div>-->
|
||||
<!-- <div-->
|
||||
<!-- v-for="(item, index) in cardList"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- class="mb-3 jyh-collapse-card"-->
|
||||
<!-- >-->
|
||||
<!-- <!– 卡片标题 –>-->
|
||||
<!-- <div class="card-header">-->
|
||||
<!-- <h4>{{ item.title }}</h4>-->
|
||||
<!-- </div>-->
|
||||
<!-- <!– 卡片内容 –>-->
|
||||
<!-- <div class="card-content">-->
|
||||
<!-- <div class="content-left">-->
|
||||
<!-- <img width="16" style="margin-right: 4px" src="@/assets/imgs/jyh/ai/aiLogo2.png" />-->
|
||||
<!-- <span>{{ item.text }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="content-right">-->
|
||||
<!-- <span class="time-text">{{ formatTime(item.time) }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </d-collapse-item>-->
|
||||
</d-collapse>
|
||||
</div>
|
||||
<!-- 固定在底部的控制栏 -->
|
||||
@@ -138,85 +123,88 @@
|
||||
<d-search icon-position="left" style="width: 100%" placeholder="请输入搜索软件名称" v-model="searchText" @change="handleSearch"></d-search>
|
||||
<!-- 可滚动内容区域 -->
|
||||
<div class="scrollable-content">
|
||||
<!-- <d-collapse class="jyh-collapse" v-model="collapseValue">-->
|
||||
<!-- <d-collapse-item name="today">-->
|
||||
<!-- <template #title>-->
|
||||
<!-- <div class="jyh-collapse-title">-->
|
||||
<!-- <d-icon style="margin-right: 4px" name="icon-delay"></d-icon>今天-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<!-- <div>-->
|
||||
<!-- <!– 循环生成卡片列表 –>-->
|
||||
<!-- <div v-if="cardList.length>0">-->
|
||||
<!-- <div-->
|
||||
<!-- v-for="(item, index) in cardList"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- :class="['mb-3 jyh-collapse-card', { 'selected-card': selectedIndex === item.id }]"-->
|
||||
<!-- @click="selectCard(item)"-->
|
||||
<!-- @mouseenter="hoverIndex = index"-->
|
||||
<!-- @mouseleave="hoverIndex = null"-->
|
||||
<!-- >-->
|
||||
<!-- <!– 卡片标题 –>-->
|
||||
<!-- <div class="card-header">-->
|
||||
<!-- <h4>{{ item.title }}</h4>-->
|
||||
<!-- <!– 悬停操作按钮 –>-->
|
||||
<!-- <div class="card-actions" v-show="hoverIndex === index">-->
|
||||
<!-- <d-tooltip content="编辑">-->
|
||||
<!-- <d-icon style="font-size: 14px;margin-right: 2px" @click.stop="handleEdit(item)" name="icon-edit-3"></d-icon>-->
|
||||
<!-- </d-tooltip>-->
|
||||
<!-- <d-tooltip content="分享">-->
|
||||
<!-- <d-icon style="font-size: 14px;margin-right: 2px" @click.stop="handleShare(item)" name="icon-redo-new"></d-icon>-->
|
||||
<!-- </d-tooltip>-->
|
||||
<!-- <d-tooltip content="更多">-->
|
||||
<!-- <d-icon style="font-size: 14px;" @click.stop="handleMore(item)" name="icon-more-operate"></d-icon>-->
|
||||
<!-- </d-tooltip>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <!– 卡片内容 –>-->
|
||||
<!-- <div class="card-content">-->
|
||||
<!-- <div class="content-left">-->
|
||||
<!-- <img width="16" style="margin-right: 4px" src="@/assets/imgs/jyh/ai/aiLogo2.png" />-->
|
||||
<!-- <span>{{ item.text }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="content-right">-->
|
||||
<!-- <span class="time-text">{{ formatTime(item.time) }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <NoData v-else :small="false"></NoData>-->
|
||||
<!-- </div>-->
|
||||
<!-- </d-collapse-item>-->
|
||||
<!-- <d-collapse-item name="yestoday">-->
|
||||
<!-- <template #title>-->
|
||||
<!-- <div class="jyh-collapse-title">-->
|
||||
<!-- <d-icon style="margin-right: 4px" name="icon-delay"></d-icon>昨天-->
|
||||
<!-- </div>-->
|
||||
<!-- </template>-->
|
||||
<!-- <div>-->
|
||||
<!-- <div-->
|
||||
<!-- v-for="(item, index) in cardList"-->
|
||||
<!-- :key="index"-->
|
||||
<!-- class="mb-3 jyh-collapse-card"-->
|
||||
<!-- >-->
|
||||
<!-- <!– 卡片标题 –>-->
|
||||
<!-- <div class="card-header">-->
|
||||
<!-- <h4>{{ item.title }}</h4>-->
|
||||
<!-- </div>-->
|
||||
<!-- <!– 卡片内容 –>-->
|
||||
<!-- <div class="card-content">-->
|
||||
<!-- <div class="content-left">-->
|
||||
<!-- <img width="16" style="margin-right: 4px" src="@/assets/imgs/jyh/ai/aiLogo2.png" />-->
|
||||
<!-- <span>{{ item.text }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="content-right">-->
|
||||
<!-- <span class="time-text">{{ formatTime(item.time) }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </d-collapse-item>-->
|
||||
<!-- </d-collapse>-->
|
||||
<d-collapse class="jyh-collapse" v-model="collapseValue">
|
||||
<d-collapse-item name="today">
|
||||
<template #title>
|
||||
<div class="jyh-collapse-title">
|
||||
<d-icon style="margin-right: 4px" name="icon-delay"></d-icon>今天
|
||||
</div>
|
||||
</template>
|
||||
<div>
|
||||
<!-- 循环生成卡片列表 -->
|
||||
<div v-if="collectionList.length>0">
|
||||
<div
|
||||
v-for="(item, index) in collectionList"
|
||||
:key="index"
|
||||
:class="['mb-3 jyh-collapse-card', { 'selected-card': props.CONV_ID === item.conversationId }]"
|
||||
@click="handleSelect(item)"
|
||||
@mouseenter="hoverIndex = index"
|
||||
@mouseleave="hoverIndex = null"
|
||||
>
|
||||
<!-- 卡片标题 -->
|
||||
<div class="card-header">
|
||||
<!-- 编辑状态切换 -->
|
||||
<template v-if="item.isEditing">
|
||||
<!-- <d-input v-model="item.tempTitle" @blur="cancelEdit(item)" @keypress.enter="confirmEdit(item)" autofocus class="edit-input" />-->
|
||||
<d-input v-model="item.tempTitle" autofocus class="edit-input" />
|
||||
<div class="card-actions">
|
||||
<d-icon
|
||||
name="icon-right"
|
||||
style="font-size: 14px;"
|
||||
@click="confirmEdit(item)"
|
||||
/>
|
||||
<d-icon
|
||||
name="icon-error"
|
||||
style="font-size: 14px;"
|
||||
@click="cancelEdit(item)"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<h4 @dblclick="startEdit(item)">{{ item.title }}</h4>
|
||||
<div class="card-actions" v-show="hoverIndex === index">
|
||||
<d-tooltip content="编辑">
|
||||
<d-icon
|
||||
style="font-size: 14px; margin-right: 2px;"
|
||||
@click.stop="startEdit(item)"
|
||||
name="icon-edit-3"
|
||||
/>
|
||||
</d-tooltip>
|
||||
<d-tooltip content="分享">
|
||||
<d-icon style="font-size: 14px;margin-right: 2px" @click.stop="handleShare(item)" name="icon-redo-new"></d-icon>
|
||||
</d-tooltip>
|
||||
<d-dropdown style="width: 100px;" align="start">
|
||||
<d-icon style="font-size: 14px;" @click.stop="handleMore(item)" name="icon-more-operate"></d-icon>
|
||||
<template #menu>
|
||||
<ul class="list-menu">
|
||||
<li class="menu-item" @click="toggleCollect(item)">
|
||||
<d-icon name="icon-star" style="font-size: 14px;padding-right: 4px" />取消收藏
|
||||
</li>
|
||||
<li class="menu-item" @click="handleDelete(item)">
|
||||
<d-icon name="icon-delete" style="font-size: 14px;padding-right: 4px" />删除
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</d-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<!-- 卡片内容 -->
|
||||
<div class="card-content">
|
||||
<div class="content-left">
|
||||
<img width="16" style="margin-right: 4px" src="@/assets/imgs/jyh/ai/aiLogo2.png" />
|
||||
<span>{{ item.text || '可信代码库AI' }}</span>
|
||||
</div>
|
||||
<div class="content-right">
|
||||
<span class="time-text">{{ item.createTime||'--' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<NoData v-else :small="false"></NoData>
|
||||
</div>
|
||||
</d-collapse-item>
|
||||
</d-collapse>
|
||||
</div>
|
||||
<!-- 固定在底部的控制栏 -->
|
||||
<div class="bottom-control-bar">
|
||||
@@ -234,15 +222,15 @@
|
||||
<d-option value="0">0</d-option>
|
||||
</d-select>
|
||||
</div>
|
||||
<!-- <div class="control-right">-->
|
||||
<!-- <d-button class="jyh-button2" variant="solid" @click="openBatchManageModal">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <d-icon name="icon-property-setting"></d-icon>-->
|
||||
<!-- </template>-->
|
||||
<!-- 批量管理-->
|
||||
<!-- </d-button>-->
|
||||
<!-- <BatchManageModal ref="BatchManageModalRef"/>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="control-right">-->
|
||||
<!-- <d-button class="jyh-button2" variant="solid" @click="openBatchManageModal">-->
|
||||
<!-- <template #icon>-->
|
||||
<!-- <d-icon name="icon-property-setting"></d-icon>-->
|
||||
<!-- </template>-->
|
||||
<!-- 批量管理-->
|
||||
<!-- </d-button>-->
|
||||
<!-- <BatchManageModal ref="BatchManageModalRef"/>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</d-tab>
|
||||
</d-tabs>
|
||||
@@ -302,7 +290,6 @@ const startEdit = (item) => {
|
||||
|
||||
// 确认编辑
|
||||
const confirmEdit = async (item) => {
|
||||
debugger
|
||||
if (!item.tempTitle.trim()) {
|
||||
Message.error('标题不能为空');
|
||||
return;
|
||||
@@ -328,9 +315,38 @@ const confirmEdit = async (item) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 收藏状态切换
|
||||
const toggleCollect = async (item) => {
|
||||
if (!props.username) {
|
||||
return Message.error('请先登录');
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await axios.post(`${VITE_AI_API_HOST}/api/toggleConversationCollect`, {
|
||||
userId: props.username,
|
||||
conversationId: item.conversationId
|
||||
});
|
||||
|
||||
if (res.data.code === 20000) {
|
||||
// 更新历史对话状态
|
||||
item.is_collected = res.data.isCollected;
|
||||
|
||||
// 刷新收藏列表
|
||||
await getQuestionCollection();
|
||||
|
||||
Message.success(res.data.message);
|
||||
} else {
|
||||
Message.error(res.data.message || '操作失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('收藏操作失败:', error);
|
||||
Message.error('网络请求失败,请重试');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 取消编辑
|
||||
const cancelEdit = (item) => {
|
||||
debugger
|
||||
item.isEditing = false;
|
||||
item.tempTitle = item.title; // 恢复原始标题
|
||||
};
|
||||
@@ -360,13 +376,13 @@ const cardList = ref([
|
||||
}
|
||||
]);
|
||||
const dhlsList = ref([]);
|
||||
const collectionList = ref([]);
|
||||
|
||||
const VITE_AI_API_HOST = import.meta.env.VITE_AI_API_HOST;
|
||||
const getQuestionHistory = async () => {
|
||||
if(props.username) {
|
||||
const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username);
|
||||
const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=history');
|
||||
if(data.conversationList) {
|
||||
debugger
|
||||
dhlsList.value = data.conversationList
|
||||
} else {
|
||||
// Message.error(data.error||'接口异常!')
|
||||
@@ -375,9 +391,22 @@ const getQuestionHistory = async () => {
|
||||
Message.error('请先登录!')
|
||||
}
|
||||
};
|
||||
const getQuestionCollection = async () => {
|
||||
if(props.username) {
|
||||
const {data} = await axios.get(VITE_AI_API_HOST + '/api/conversationList?userId='+props.username + '&list_type=collection');
|
||||
if(data.conversationList) {
|
||||
collectionList.value = data.conversationList
|
||||
} else {
|
||||
// Message.error(data.error||'接口异常!')
|
||||
}
|
||||
} else {
|
||||
Message.error('请先登录!')
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getQuestionHistory()
|
||||
getQuestionCollection()
|
||||
});
|
||||
|
||||
defineExpose({
|
||||
@@ -467,4 +496,15 @@ defineExpose({
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.list-menu {
|
||||
padding: 8px;
|
||||
.menu-item {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
//justify-content: space-around;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user