From 4c9cc17366e5916c78e6244497d5eb3cc1a840ef Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Sun, 18 May 2025 15:58:47 +0800 Subject: [PATCH] =?UTF-8?q?refactor(@vben/common-ui):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=B8=89=E4=B8=AA=E5=B7=A5=E4=BD=9C=E8=A7=86=E5=9B=BE=E7=9A=84?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E5=92=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为用户和 AI 气泡添加白色背景样式 -修复文件下载时的文件名问题 - 移除或注释掉不必要的代码 - 添加对项目名称和内容的验证 -优化通知消息的显示 --- .../common-ui/src/ui/ppt/ppt-work-view.vue | 12 +- .../src/ui/spider/spider-list-view.vue | 82 +++++------ .../src/ui/spider/spider-work-view.vue | 92 +++--------- .../common-ui/src/ui/word/word-work-view.vue | 135 ++++++++++-------- 4 files changed, 143 insertions(+), 178 deletions(-) diff --git a/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue b/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue index 3b73ee1..f5a383c 100644 --- a/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue +++ b/packages/effects/common-ui/src/ui/ppt/ppt-work-view.vue @@ -74,6 +74,11 @@ const roles: BubbleListProps['roles'] = { user: { placement: 'end', typing: false, + styles: { + content: { + background: '#ffffff', + }, + }, avatar: { icon: h(UserOutlined), style: { background: '#87d068' } }, }, ai: { @@ -84,6 +89,9 @@ const roles: BubbleListProps['roles'] = { marginInlineEnd: 44, }, styles: { + content: { + background: '#ffffff', + }, footer: { width: '100%', }, @@ -232,7 +240,7 @@ const startFetching = async () => { // 创建隐藏的 标签用于触发下载 const link = document.createElement('a'); link.href = result; // 设置下载链接 - link.download = filename; // 设置下载文件名 + link.download = filename.value; // 设置下载文件名 document.body.append(link); // 将 标签添加到页面中 link.click(); // 触发点击事件开始下载 link.remove(); // 下载完成后移除 标签 @@ -307,7 +315,7 @@ watch( // 创建隐藏的 标签用于触发下载 const link = document.createElement('a'); link.href = msg.content; // 设置下载链接 - link.download = filename; // 设置下载文件名 + link.download = filename.value; // 设置下载文件名 document.body.append(link); // 将 标签添加到页面中 link.click(); // 触发点击事件开始下载 link.remove(); // 下载完成后移除 标签 diff --git a/packages/effects/common-ui/src/ui/spider/spider-list-view.vue b/packages/effects/common-ui/src/ui/spider/spider-list-view.vue index fb54670..dfdfd6c 100644 --- a/packages/effects/common-ui/src/ui/spider/spider-list-view.vue +++ b/packages/effects/common-ui/src/ui/spider/spider-list-view.vue @@ -1,40 +1,40 @@ diff --git a/packages/effects/common-ui/src/ui/spider/spider-work-view.vue b/packages/effects/common-ui/src/ui/spider/spider-work-view.vue index ebbbcb9..3572e60 100644 --- a/packages/effects/common-ui/src/ui/spider/spider-work-view.vue +++ b/packages/effects/common-ui/src/ui/spider/spider-work-view.vue @@ -344,82 +344,6 @@ const startFetching = async () => { } isFetching.value = false; } - - // try { - // notification.info({ - // message: '正在获取中...', - // duration: 3, - // }); - // const res = await props.runSpider( - // { - // publish_start_time, - // publish_end_time, - // llm_api_key: '77c068fd-d5b6-4c33-97d8-db5511a09b26', - // }, - // ); - // if (res.data.outputs.result) { - // // 保存抓取结果 - // fetchResult.value = res.data.outputs.result; - // notification.success({ - // message: '获取成功', - // duration: 3, - // }); - // const { result } = res.data.outputs; - // - // const filename = ref(''); - // - // if (result && isDocxURL(result)) { - // filename.value = extractDocxFilename(result); - // } - // - // // 保存抓取结果 url http://47.112.173.8:6802/static/66f3cfd95e364a239d8036390db658ae.docx - // fetchResult.value = `/static/${filename.value}`; - // resultItems.value.push({ - // key: resultItems.value.length + 1, - // role: 'ai', - // content: '文档已生成', - // footer: h(Flex, null, [ - // h( - // Button, - // { - // size: 'nomarl', - // type: 'primary', - // onClick: () => { - // openPreviewDrawer('right', filename); - // }, - // }, - // '文档预览', - // ), - // h( - // Button, - // { - // size: 'normal', - // type: 'primary', - // style: { - // marginLeft: '10px', - // }, - // onClick: () => { - // // 创建隐藏的 标签用于触发下载 - // const link = document.createElement('a'); - // link.href = msg.content; // 设置下载链接 - // link.download = filename; // 设置下载文件名 - // document.body.append(link); // 将 标签添加到页面中 - // link.click(); // 触发点击事件开始下载 - // link.remove(); // 下载完成后移除 标签 - // }, - // }, - // '文档下载', - // ), - // ]), - // }); - // fetchStatus.value = 'completed'; - // } else { - // fetchResult.value = ''; - // message.error('抓取无结果'); - // } - // } catch (error) { - // message.error(`${error}`); - // } }; // 列表角色 @@ -427,6 +351,11 @@ const roles: BubbleListProps['roles'] = { user: { placement: 'end', typing: false, + styles: { + content: { + background: '#ffffff', + }, + }, avatar: { icon: h(UserOutlined), style: { background: '#87d068' } }, }, ai: { @@ -437,6 +366,9 @@ const roles: BubbleListProps['roles'] = { marginInlineEnd: 44, }, styles: { + content: { + background: '#ffffff', + }, footer: { width: '100%', }, @@ -462,6 +394,14 @@ const isFetching = ref(false); const fetchResult = ref(''); const fetchStatus = ref(''); +// 监听 title 变化并更新 resultItems +watch( + () => props.title, + () => { + resultItems.value = []; + }, +); + // 监听 itemMessage 变化并更新 resultItems watch( () => props.itemMessage, diff --git a/packages/effects/common-ui/src/ui/word/word-work-view.vue b/packages/effects/common-ui/src/ui/word/word-work-view.vue index c645e08..8c5e296 100644 --- a/packages/effects/common-ui/src/ui/word/word-work-view.vue +++ b/packages/effects/common-ui/src/ui/word/word-work-view.vue @@ -14,8 +14,9 @@ import { computed, h, ref, watch } from 'vue'; import { useVbenDrawer } from '@vben-core/popup-ui'; import { - CloudUploadOutlined, - PaperClipOutlined, + EditOutlined, + // CloudUploadOutlined, + // PaperClipOutlined, UserOutlined, } from '@ant-design/icons-vue'; // import type { VNode } from 'vue'; @@ -27,6 +28,7 @@ import { FormItem, Input, Modal, + notification, Space, Textarea, Typography, @@ -147,17 +149,27 @@ const senderPromptsItems = computed(() => { const roles: BubbleListProps['roles'] = { user: { placement: 'end', + variant: 'shadow', typing: false, + styles: { + content: { + background: '#ffffff', + }, + }, avatar: { icon: h(UserOutlined), style: { background: '#87d068' } }, }, ai: { placement: 'start', + variant: 'shadow', typing: false, style: { maxWidth: 600, marginInlineEnd: 44, }, styles: { + content: { + background: '#ffffff', + }, footer: { width: '100%', }, @@ -260,10 +272,19 @@ function extractDocxFilename(url: string): null | string { } return null; } -const showModal = () => { - open.value = true; -}; const startFetching = async () => { + if (projectInfo.value.projectName === '') { + open.value = true; + return; + } + if (content.value === '') { + notification.warn({ + message: '请输入项目内容', + description: '请在输入框中输入项目内容', + }); + open.value = false; + return; + } open.value = false; agentRequestLoading.value = true; fetchStatus.value = 'fetching'; @@ -328,7 +349,7 @@ const startFetching = async () => { // 创建隐藏的 标签用于触发下载 const link = document.createElement('a'); link.href = answer; // 设置下载链接 - link.download = filename; // 设置下载文件名 + link.download = filename.value; // 设置下载文件名 document.body.append(link); // 将 标签添加到页面中 link.click(); // 触发点击事件开始下载 link.remove(); // 下载完成后移除 标签 @@ -360,8 +381,8 @@ const onPromptsItemClick: PromptsProps['onItemClick'] = (info) => { content.value = info.data.description; }; -const handleFileChange: AttachmentsProps['onChange'] = (info) => - (attachedFiles.value = info.fileList); +// const handleFileChange: AttachmentsProps['onChange'] = (info) => +// (attachedFiles.value = info.fileList); // 监听 itemMessage 变化并更新 resultItems watch( @@ -410,7 +431,7 @@ watch( // 创建隐藏的 标签用于触发下载 const link = document.createElement('a'); link.href = msg.content; // 设置下载链接 - link.download = filename; // 设置下载文件名 + link.download = filename.value; // 设置下载文件名 document.body.append(link); // 将 标签添加到页面中 link.click(); // 触发点击事件开始下载 link.remove(); // 下载完成后移除 标签 @@ -446,23 +467,19 @@ watch( placeholder="请输入项目名称" /> - +