From 56a09d7b2ca47a2c7ec1024435660106544c1cd8 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Tue, 19 Nov 2024 15:29:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=A0=B9=E6=8D=AE=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=B1=BB=E5=9E=8B=E9=99=90=E5=88=B6=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/chat-input-operate/index.vue | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ui/src/components/ai-chat/component/chat-input-operate/index.vue b/ui/src/components/ai-chat/component/chat-input-operate/index.vue index 0174c1612..d4524fde2 100644 --- a/ui/src/components/ai-chat/component/chat-input-operate/index.vue +++ b/ui/src/components/ai-chat/component/chat-input-operate/index.vue @@ -80,9 +80,7 @@ action="#" :auto-upload="false" :show-file-list="false" - :accept=" - [...imageExtensions, ...documentExtensions].map((ext) => '.' + ext).join(',') - " + :accept="getAcceptList()" :on-change="(file: any, fileList: any) => uploadFile(file, fileList)" > @@ -191,6 +189,24 @@ const documentExtensions = ['pdf', 'docx', 'txt', 'xls', 'xlsx', 'md', 'html', ' const videoExtensions = ['mp4', 'avi', 'mov', 'mkv', 'flv'] const audioExtensions = ['mp3', 'wav', 'aac', 'flac'] +const getAcceptList = () => { + const { image, document, audio, video } = props.applicationDetails.file_upload_setting + let accepts = '' + if (image) { + accepts += imageExtensions.map((ext) => '.' + ext).join(',') + } + if (document) { + accepts += documentExtensions.map((ext) => '.' + ext).join(',') + } + if (audio) { + accepts += audioExtensions.map((ext) => '.' + ext).join(',') + } + if (video) { + accepts += videoExtensions.map((ext) => '.' + ext).join(',') + } + return accepts +} + const uploadFile = async (file: any, fileList: any) => { const { maxFiles, fileLimit } = props.applicationDetails.file_upload_setting if (fileList.length > maxFiles) {