yangyin
2024-11-26 2e949e1e25db238f021ba6c1f033b79b1a13af69
联调聊天记录重命名
已修改3个文件
75 ■■■■■ 文件已修改
src/api/ai/chat.ts 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/component/sidebar/SidebarOther.vue 37 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/layout/component/sidebar/components/ChatRecord.vue 34 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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',
        },
    });
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
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);