From c0d0f53baad07336b3641cc28c5fade8cc08f665 Mon Sep 17 00:00:00 2001 From: wangdan-fit2cloud Date: Wed, 10 Apr 2024 15:50:57 +0800 Subject: [PATCH] =?UTF-8?q?fit:=20=E6=96=87=E4=BB=B6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/utils/utils.ts | 8 ++++++-- ui/src/views/dataset/component/UploadComponent.vue | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ui/src/utils/utils.ts b/ui/src/utils/utils.ts index 68c01a00b..7907a5436 100644 --- a/ui/src/utils/utils.ts +++ b/ui/src/utils/utils.ts @@ -39,10 +39,14 @@ export function fileType(name: string) { 获得文件对应图片 */ export function getImgUrl(name: string) { - const typeList = ['txt', 'pdf', 'doc', 'csv', 'md'] - const type = typeList.includes(fileType(name)) ? fileType(name) : 'unknow' + const type = isRightType(name) ? fileType(name) : 'unknow' return new URL(`../assets/${type}-icon.svg`, import.meta.url).href } +// 是否是白名单后缀 +export function isRightType(name: string) { + const typeList = ['txt', 'pdf', 'doc', 'csv', 'md'] + return typeList.includes(fileType(name)) +} /* 从指定数组中过滤出对应的对象 diff --git a/ui/src/views/dataset/component/UploadComponent.vue b/ui/src/views/dataset/component/UploadComponent.vue index d83731cdd..25e150cd1 100644 --- a/ui/src/views/dataset/component/UploadComponent.vue +++ b/ui/src/views/dataset/component/UploadComponent.vue @@ -61,7 +61,7 @@