From ea24bd60c42e8284415e37e7992768a470abe777 Mon Sep 17 00:00:00 2001 From: yangyin <1850366751@qq.com> Date: 星期二, 26 十一月 2024 10:28:18 +0800 Subject: [PATCH] 增加重命名管理 --- src/components/chat/Chat.vue | 10 +--------- src/layout/component/sidebar/SidebarOther.vue | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index eec5621..6424b86 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -275,15 +275,7 @@ <div class="sticky bottom-0 w-full p-6 bg-[rgb(247,248,250)] flex justify-center" v-if="isShareCheck"></div> </div> <CustomDrawer v-model:isShow="drawerIsShow" @updateChatInput="updateChatInput" /> - <el-dialog - title="鍒嗕韩閾炬帴" - v-model="shareCodeIsShow" - width="25%" - center - modal-append-to-body - lock-scroll - :before-close="closeShareClick" - > + <el-dialog title="鍒嗕韩閾炬帴" v-model="shareCodeIsShow" width="25%" modal-append-to-body lock-scroll :before-close="closeShareClick"> <div class="w100 h100 flex justify-center items-center flex-col"> <div class="qrcode h100" ref="qrcodeRef"></div> <div class="h100 w100 flex flex-col justify-center items-center"> diff --git a/src/layout/component/sidebar/SidebarOther.vue b/src/layout/component/sidebar/SidebarOther.vue index 6490b1d..7615c23 100644 --- a/src/layout/component/sidebar/SidebarOther.vue +++ b/src/layout/component/sidebar/SidebarOther.vue @@ -81,6 +81,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> <el-popconfirm title="纭畾鍒犻櫎鑱婂ぉ璁板綍?" @confirm.stop="confirmDeleteChatRoom(item)" width="180"> <template #reference> <div class="ywifont invisible ywicon-shanchu3 group-hover:visible"></div> @@ -103,11 +104,21 @@ </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> <script setup lang="ts"> import { onClickOutside } from '@vueuse/core'; +import { ElMessage, ElMessageBox } from 'element-plus'; import moment from 'moment'; import { computed, onMounted, ref, watch, watchEffect } from 'vue'; import type { ChatRoomItem } from './components/types'; @@ -144,6 +155,8 @@ const queryParams = ref({ title: '', }); +const userRenameVisible = ref(false); +const userRenameText = ref(''); const historyChatRoomClick = () => { isShowHistoryChatRoom.value = true; }; @@ -165,10 +178,35 @@ roomClick(chatRoomList.value[0]); chatRoomRef.value.firstElementChild?.scrollIntoView(); }; - -onClickOutside(historyChatRoomRef, () => { - isShowHistoryChatRoom.value = false; -}); +const editChat = (room: ChatRoomItem) => { + ElMessageBox.prompt('', '閲嶅懡鍚�', { + confirmButtonText: '纭', + cancelButtonText: '鍙栨秷', + inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/, + 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; + }) + .catch(({ value }) => { + ElMessage({ + type: 'info', + message: '鍙栨秷淇敼', + }); + }); +}; +onClickOutside( + historyChatRoomRef, + () => { + isShowHistoryChatRoom.value = false; + }, + { + ignore: ['.el-message-box'], + } +); //#endregion //#region ====================== 鍏徃淇℃伅 ====================== const companyClick = () => { -- Gitblit v1.9.3