From 4518ef74eb6cb6f449fa2e2f74956100fa881c20 Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Tue, 6 May 2025 21:06:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor(@vben/common-ui):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=94=9F=E6=88=90=E5=92=8C=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common-ui/src/ui/word/word-work-view.vue | 82 ++++++++++--------- 1 file changed, 44 insertions(+), 38 deletions(-) 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 b24583b..5f76b38 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 @@ -134,47 +134,53 @@ const startFetching = async () => { if (answer && isDocxURL(answer)) { filename.value = extractDocxFilename(answer); + 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: 'nomarl', + type: 'primary', + style: { + marginLeft: '10px', + }, + onClick: () => { + // 创建隐藏的 标签用于触发下载 + const link = document.createElement('a'); + link.href = answer; // 设置下载链接 + link.download = filename; // 设置下载文件名 + document.body.append(link); // 将 标签添加到页面中 + link.click(); // 触发点击事件开始下载 + link.remove(); // 下载完成后移除 标签 + }, + }, + '文档下载', + ), + ]), + }); + } else { + resultItems.value.push({ + key: resultItems.value.length + 1, + role: 'ai', + content: res.answer, + }); } fetchResult.value = `/static/${filename.value}`; - resultItems.value.push({ - key: resultItems.value.length + 1, - role: 'ai', - content: res.answer, - footer: h(Flex, null, [ - h( - Button, - { - size: 'nomarl', - type: 'primary', - onClick: () => { - openPreviewDrawer('right', filename); - }, - }, - '文档预览', - ), - h( - Button, - { - size: 'nomarl', - type: 'primary', - style: { - marginLeft: '10px', - }, - onClick: () => { - // 创建隐藏的 标签用于触发下载 - const link = document.createElement('a'); - link.href = answer; // 设置下载链接 - link.download = filename; // 设置下载文件名 - document.body.append(link); // 将 标签添加到页面中 - link.click(); // 触发点击事件开始下载 - link.remove(); // 下载完成后移除 标签 - }, - }, - '文档下载', - ), - ]), - }); // resultItems.value.push({ // key: resultItems.value.length + 1, // role: 'ai',