From 9b771e02ec31af1238f9662e839df6197f501376 Mon Sep 17 00:00:00 2001 From: nongyehong <2439646234@qq.com> Date: Tue, 2 Jul 2024 01:03:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(component):=20:sparkles:=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9EGPT=E6=AC=A2=E8=BF=8E=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/hooks/useChatMain.ts | 4 +- src/hooks/useMsgInput.ts | 2 +- src/router/index.ts | 5 + src/styles/scss/chat-main.scss | 2 +- src/views/home-window/robot/layout/Left.vue | 41 ++-- src/views/home-window/robot/views/Chat.vue | 1 + src/views/home-window/robot/views/Welcome.vue | 100 ++++++++++ .../robot/views/chatSettings/config.tsx | 180 ++++++++++++++++-- .../robot/views/chatSettings/index.vue | 37 ++-- .../robot/views/chatSettings/model.tsx | 128 +++++++++---- src/views/login-window/QRCode.vue | 2 +- 12 files changed, 420 insertions(+), 84 deletions(-) create mode 100644 src/views/home-window/robot/views/Welcome.vue diff --git a/index.html b/index.html index e988787d..b3f185e4 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ HuLa - + diff --git a/src/hooks/useChatMain.ts b/src/hooks/useChatMain.ts index 9ba343e3..23ee90bd 100644 --- a/src/hooks/useChatMain.ts +++ b/src/hooks/useChatMain.ts @@ -115,7 +115,7 @@ export const useChatMain = (activeItem?: SessionItem) => { ...commonMenuList.value, { label: '另存为', - icon: 'download', + icon: 'Importing', click: (item: any) => { console.log(item) } @@ -142,7 +142,7 @@ export const useChatMain = (activeItem?: SessionItem) => { ...commonMenuList.value, { label: '另存为', - icon: 'download', + icon: 'Importing', click: (item: any) => { console.log(item) } diff --git a/src/hooks/useMsgInput.ts b/src/hooks/useMsgInput.ts index 798947f5..941d8fde 100644 --- a/src/hooks/useMsgInput.ts +++ b/src/hooks/useMsgInput.ts @@ -72,7 +72,7 @@ export const useMsgInput = (messageInputDom: Ref) => { }) } }, - { label: '另存为', icon: 'download', disabled: true }, + { label: '另存为', icon: 'Importing', disabled: true }, { label: '全部选择', icon: 'check-one' } ]) diff --git a/src/router/index.ts b/src/router/index.ts index 1f8ff446..049b51c0 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -46,6 +46,11 @@ const routes: Array = [ name: 'robot', component: () => import('@/views/home-window/robot/index.vue'), children: [ + { + path: '/welcome', + name: 'welcome', + component: () => import('@/views/home-window/robot/views/Welcome.vue') + }, { path: '/chat', name: 'chat', diff --git a/src/styles/scss/chat-main.scss b/src/styles/scss/chat-main.scss index 6d008e18..63ce38a3 100644 --- a/src/styles/scss/chat-main.scss +++ b/src/styles/scss/chat-main.scss @@ -75,7 +75,7 @@ } /** emoji回复气泡的样式 */ .emoji-reply-bubble { - @apply relative rounded-50px p-[4px_8px] cursor-pointer select-none bg-#13987F66 text-14px w-fit border-(1px solid #13987F); + @apply relative rounded-50px p-[4px_8px] cursor-pointer select-none bg-#13987F66 text-14px w-fit border-(1px solid #13987F) shadow-md; } /** 跳转到回复内容时候显示的样式 */ .active-reply { diff --git a/src/views/home-window/robot/layout/Left.vue b/src/views/home-window/robot/layout/Left.vue index c1829139..7f39bedf 100644 --- a/src/views/home-window/robot/layout/Left.vue +++ b/src/views/home-window/robot/layout/Left.vue @@ -199,6 +199,26 @@ const add = () => { const deleteChat = (item: any) => { // 根据key找到items中对应的下标 const index = chatList.value.indexOf(item) + + /** + * 删除最后一个元素后触发新增元素的函数 + * @param isActive 是否选中新增的元素 + */ + function triggeringAdd(isActive?: boolean) { + if (chatList.value.length === 0) { + nextTick(() => { + add() + // 选择新增的元素 + if (isActive) { + handleActive(chatList.value[0]) + window.$message.success(`已删除 ${item.title}`, { + icon: () => h(NIcon, null, { default: () => h('svg', null, [h('use', { href: '#face' })]) }) + }) + } + }) + } + } + // 如果找到了对应的元素,则移除 if (index !== -1) { const removeItem = chatList.value.splice(index, 1)[0] @@ -208,22 +228,15 @@ const deleteChat = (item: any) => { activeItem.value = chatList.value[index].id handleActive(chatList.value[index]) } else { - // 如果是最后一个元素则触发新增 - if (chatList.value.length === 0) { - nextTick(() => { - add() - // 选择新增的元素 - handleActive(chatList.value[0]) - window.$message.success(`已删除 ${item.title}`, { - icon: () => h(NIcon, null, { default: () => h('svg', null, [h('use', { href: '#face' })]) }) - }) - }) - } + // 如果选中chatList,并且是最后一个元素则触发新增 + triggeringAdd(true) // 如果我们删除的是最后一个元素,则需要选中前一个元素 activeItem.value = chatList.value[chatList.value.length - 1].id handleActive(chatList.value[chatList.value.length - 1]) } } + // 如果是最后一个元素则触发新增 + triggeringAdd() window.$message.success(`已删除 ${item.title}`, { icon: () => h(NIcon, null, { default: () => h('svg', null, [h('use', { href: '#face' })]) }) }) @@ -231,8 +244,10 @@ const deleteChat = (item: any) => { } onMounted(() => { - /** 默认选择第一个聊天内容 */ - handleActive(chatList.value[0]) + // /** 默认选择第一个聊天内容 */ + // handleActive(chatList.value[0]) + /** 刚加载的时候默认跳转到欢迎页面 */ + router.push('/welcome') Mitt.on('update-chat-title', (e) => { chatList.value.filter((item) => { if (item.id === e.id) { diff --git a/src/views/home-window/robot/views/Chat.vue b/src/views/home-window/robot/views/Chat.vue index c11f1dc2..5692ee75 100644 --- a/src/views/home-window/robot/views/Chat.vue +++ b/src/views/home-window/robot/views/Chat.vue @@ -1,5 +1,6 @@