From 655eca8e4d474706efc82b765864c3e19c1019d9 Mon Sep 17 00:00:00 2001 From: Kven <2955163637@qq.com> Date: Wed, 25 Jun 2025 23:16:19 +0800 Subject: [PATCH] =?UTF-8?q?refactor(@vben/web-antd):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20Word=E6=A8=A1=E5=9D=97=E7=9A=84=E5=B1=9E=E6=80=A7=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E5=92=8C=E7=B1=BB=E5=9E=8B=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 typing.ts 中的 Props接口 - 优化 extractDocxInfo 函数的返回类型,增加对 filename 的 undefined 支持 --- .../views/word/components/word-work-view.vue | 52 ++++++++++--------- apps/web-antd/src/views/word/typing.ts | 2 +- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/apps/web-antd/src/views/word/components/word-work-view.vue b/apps/web-antd/src/views/word/components/word-work-view.vue index f763b21..8de4c98 100644 --- a/apps/web-antd/src/views/word/components/word-work-view.vue +++ b/apps/web-antd/src/views/word/components/word-work-view.vue @@ -7,7 +7,7 @@ import type { import type { DrawerPlacement } from '@vben/common-ui'; -import type { Props, ResultItem, WordTempItem } from '../typing'; +import type { Props, ResultItem } from '../typing'; import { computed, h, ref, watch } from 'vue'; @@ -42,26 +42,32 @@ import WordPreview from './word-preview.vue'; defineOptions({ name: 'WordWorkView' }); const props = withDefaults(defineProps(), { - item: { - id: '', - name: '', - } as WordTempItem, + item: () => { + return { + id: '', + name: '', + }; + }, itemMessage: Array, paramsData: Array, - runChatFlow: () => async () => ({ - event: '', - conversationId: '', - messageFiles: [], - messageId: '', - taskId: '', - id: '', - answer: '', - }), - projectInfo: { - projectName: '', - projectContext: '', - projectKeyAvoidTechOrKeyword: '', - userInitialInnovationPoint: '', + runChatFlow: () => { + return { + event: '', + conversationId: '', + messageFiles: [], + messageId: '', + taskId: '', + id: '', + answer: '', + }; + }, + projectInfo: () => { + return { + projectContext: '', + projectKeyAvoidTechOrKeyword: '', + projectName: '', + userInitialInnovationPoint: '', + }; }, }); @@ -182,7 +188,7 @@ function openPreviewDrawer( // ==================== Event ==================== function extractDocxInfo( markdownLink: string, -): null | { filename: string; url: string } { +): null | { filename: string | undefined; url: string } { const fileRegex = /\[(.*?)\]/; const urlRegex = /\((.*?)\)/; const fileMatch = markdownLink.match(fileRegex); @@ -254,7 +260,6 @@ const startFetching = async () => { h( Button, { - size: 'normal', type: 'primary', onClick: () => { openPreviewDrawer('right', url); @@ -265,13 +270,12 @@ const startFetching = async () => { h( Button, { - size: 'normal', type: 'primary', style: { marginLeft: '10px' }, onClick: () => { const link = document.createElement('a'); link.href = url; - link.download = filename; + link.download = filename as string; document.body.append(link); link.click(); link.remove(); @@ -321,7 +325,6 @@ watch( h( Button, { - size: 'normal', type: 'primary', onClick: () => { openPreviewDrawer('right', url); @@ -332,7 +335,6 @@ watch( h( Button, { - size: 'normal', type: 'primary', style: { marginLeft: '10px' }, onClick: () => { diff --git a/apps/web-antd/src/views/word/typing.ts b/apps/web-antd/src/views/word/typing.ts index 6f4c9d5..0a6b7ce 100644 --- a/apps/web-antd/src/views/word/typing.ts +++ b/apps/web-antd/src/views/word/typing.ts @@ -48,7 +48,7 @@ interface WorkflowResult { } interface Props { itemMessage?: ResultItem[]; - item?: null | WordTempItem; + item?: WordTempItem; paramsData?: string[]; runChatFlow?: ( appId: null | string,