From 2e949e1e25db238f021ba6c1f033b79b1a13af69 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 26 十一月 2024 11:42:11 +0800 Subject: [PATCH] 联调聊天记录重命名 --- src/api/ai/chat.ts | 4 + src/layout/component/sidebar/components/ChatRecord.vue | 34 ++++++++++++++-- src/layout/component/sidebar/SidebarOther.vue | 37 +++++++++--------- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/api/ai/chat.ts b/src/api/ai/chat.ts index e74f3b5..bf17923 100644 --- a/src/api/ai/chat.ts +++ b/src/api/ai/chat.ts @@ -300,7 +300,7 @@ }, }); }; - +//淇敼瀵硅瘽鍒嗙粍鍒楄〃鏍囬 export const setHistoryGroupTitle = async (params, req: any = request) => { return req({ url: 'history/set_history_group_title', @@ -502,3 +502,5 @@ 'Content-Type': 'application/x-www-form-urlencoded', }, }); + + diff --git a/src/layout/component/sidebar/SidebarOther.vue b/src/layout/component/sidebar/SidebarOther.vue index 7615c23..a1fe446 100644 --- a/src/layout/component/sidebar/SidebarOther.vue +++ b/src/layout/component/sidebar/SidebarOther.vue @@ -41,6 +41,12 @@ <span class="use_name">鐧�</span> </div> </div> + <div class="agent_line"></div> + <div class="nav__chat" @click="newChatRoomClick()"> + <div class="nav__chat-icon"> + <span class="chat_img ywifont ywicon-weixin !text-[26px] text-[#fff]"></span> + </div> + </div> </div> </div> <div class="nav_history_list bg-[#1c1e1d]" v-show="isShowHistoryChatRoom" ref="historyChatRoomRef"> @@ -81,7 +87,7 @@ <div class="ywifont ywicon-xiaoxi1 flex-0 mr-2.5"></div> <div class="flex-auto text-ellipsis text-nowrap text-sm group-hover:text-[#0084ff]">{{ item.title }}</div> <div class="text-gray-100 flex items-center space-x-2 ml-1"> - <div class="ywifont invisible ywicon-bianji group-hover:visible" @click.stop="editChat(item)"></div> + <div class="ywifont invisible ywicon-bianji group-hover:visible !text-sm" @click="editChat(item)"></div> <el-popconfirm title="纭畾鍒犻櫎鑱婂ぉ璁板綍?" @confirm.stop="confirmDeleteChatRoom(item)" width="180"> <template #reference> <div class="ywifont invisible ywicon-shanchu3 group-hover:visible"></div> @@ -104,15 +110,6 @@ </div> </template> </el-dialog> - <!-- <el-dialog v-model="userRenameVisible" title="閲嶅懡鍚�" width="500" :before-close="handleCloseRename" class="el-dialog-rename"> - <el-input v-model="userRenameText" :rows="8" type="textarea" /> - <template #footer> - <div class="dialog-footer"> - <el-button @click="handleCloseRename">鍙栨秷</el-button> - <el-button type="primary" @click="confirmRename"> 纭� 瀹� </el-button> - </div> - </template> - </el-dialog> --> </div> </template> @@ -122,7 +119,7 @@ import moment from 'moment'; import { computed, onMounted, ref, watch, watchEffect } from 'vue'; import type { ChatRoomItem } from './components/types'; -import { DeleteHistoryGroups } from '/@/api/ai/chat'; +import { DeleteHistoryGroups, setHistoryGroupTitle } from '/@/api/ai/chat'; import { useSearch } from '/@/hooks/useSearch'; import { DateFilter, dateFilterMap } from '/@/model/types/date'; import { @@ -155,8 +152,6 @@ const queryParams = ref({ title: '', }); -const userRenameVisible = ref(false); -const userRenameText = ref(''); const historyChatRoomClick = () => { isShowHistoryChatRoom.value = true; }; @@ -186,10 +181,16 @@ inputValue: room.title, inputErrorMessage: '璇疯緭鍏ユ柊鐨勫悕绉�', }) - .then((value) => { - const foundIndex = chatRoomList.value.findIndex((item) => item.id === activeRoomId.value); - chatRoomList.value[foundIndex].title = userRenameText.value; - userRenameVisible.value = false; + .then(async (edit) => { + const res = await setHistoryGroupTitle({ + history_group_id: room.id, + title: edit.value, + }); + if (res.json_ok) { + const foundIndex = chatRoomList.value.findIndex((item) => item.id === activeRoomId.value); + chatRoomList.value[foundIndex].title = edit.value; + chatRoomRef.value.firstElementChild?.scrollIntoView(); + } }) .catch(({ value }) => { ElMessage({ @@ -204,7 +205,7 @@ isShowHistoryChatRoom.value = false; }, { - ignore: ['.el-message-box'], + ignore: ['.el-message-box', '.el-popper'], } ); //#endregion diff --git a/src/layout/component/sidebar/components/ChatRecord.vue b/src/layout/component/sidebar/components/ChatRecord.vue index e959c1a..644f548 100644 --- a/src/layout/component/sidebar/components/ChatRecord.vue +++ b/src/layout/component/sidebar/components/ChatRecord.vue @@ -49,8 +49,7 @@ <div class="ywifont ywicon-xiaoxi1 flex-0 mr-2.5"></div> <div class="flex-auto text-ellipsis text-nowrap text-sm group-hover:text-[#0084ff]">{{ item.title }}</div> <div class="text-gray-100 flex items-center space-x-2 ml-1"> - <!-- <div class="ywifont invisible ywicon-bianji group-hover:visible !text-sm"></div> --> - + <div class="ywifont invisible ywicon-bianji group-hover:visible !text-sm" @click.stop="editChat(item)"></div> <el-popconfirm title="纭畾鍒犻櫎鑱婂ぉ璁板綍?" @confirm.stop="confirmDeleteChatRoom(item)" width="180"> <template #reference> <div class="ywifont invisible ywicon-shanchu3 group-hover:visible"></div> @@ -65,15 +64,15 @@ <script setup lang="ts"> import { Search } from '@element-plus/icons-vue'; +import { ElMessage, ElMessageBox } from 'element-plus'; import moment from 'moment'; import { computed, onMounted, ref, watch } from 'vue'; import type { ChatRoomItem } from './types'; -import { DeleteHistoryGroups } from '/@/api/ai/chat'; +import { DeleteHistoryGroups, setHistoryGroupTitle } from '/@/api/ai/chat'; import { useSearch } from '/@/hooks/useSearch'; import { DateFilter, dateFilterMap } from '/@/model/types/date'; import { activeRoomId, chatRoomList, gotoAnswerPage, newChatRoomClick } from '/@/stores/chatRoom'; import { debounce, getRecentDateRange } from '/@/utils/util'; - const chatRoomRef = ref<HTMLDivElement>(null); const queryParams = ref({ title: '', @@ -99,7 +98,32 @@ roomClick(chatRoomList.value[0]); chatRoomRef.value.firstElementChild?.scrollIntoView(); }; - +const editChat = (room: ChatRoomItem) => { + ElMessageBox.prompt('', '閲嶅懡鍚�', { + confirmButtonText: '纭', + cancelButtonText: '鍙栨秷', + inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/, + inputValue: room.title, + inputErrorMessage: '璇疯緭鍏ユ柊鐨勫悕绉�', + }) + .then(async (edit) => { + const res = await setHistoryGroupTitle({ + history_group_id: room.id, + title: edit.value, + }); + if (res.json_ok) { + const foundIndex = chatRoomList.value.findIndex((item) => item.id === activeRoomId.value); + chatRoomList.value[foundIndex].title = edit.value; + chatRoomRef.value.firstElementChild?.scrollIntoView(); + } + }) + .catch(({ value }) => { + ElMessage({ + type: 'info', + message: '鍙栨秷淇敼', + }); + }); +}; //#region ====================== 鏃ユ湡绛涢�� ====================== const activeDateFilter = ref<DateFilter>(DateFilter.All); -- Gitblit v1.9.3