From 8dec406161c24c2a15de630fd978b3f562392d3e Mon Sep 17 00:00:00 2001 From: Joel Date: Tue, 19 Dec 2023 14:03:24 +0800 Subject: [PATCH] chore: enchance ext name (#1787) --- .../datasets/create/file-uploader/index.tsx | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/web/app/components/datasets/create/file-uploader/index.tsx b/web/app/components/datasets/create/file-uploader/index.tsx index a8b9f5e9c4..4a6bcd7eb3 100644 --- a/web/app/components/datasets/create/file-uploader/index.tsx +++ b/web/app/components/datasets/create/file-uploader/index.tsx @@ -41,6 +41,38 @@ const FileUploader = ({ const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) const { data: supportFileTypesResponse } = useSWR({ url: '/files/support-type' }, fetchSupportFileTypes) const supportTypes = supportFileTypesResponse?.allowed_extensions || [] + const supportTypesShowNames = (() => { + let res = [...supportTypes] + if (res.includes('markdown') && res.includes('md')) + res = res.filter(item => item !== 'md') + + if (res.includes('pptx') && res.includes('ppt')) + res = res.filter(item => item !== 'ppt') + + if (res.includes('html') && res.includes('htm')) + res = res.filter(item => item !== 'htm') + + res = res.map((item) => { + if (item === 'md') + return 'markdown' + + if (item === 'pptx') + return 'ppt' + + if (item === 'htm') + return 'html' + + if (item === 'xlsx') + return 'xls' + + if (item === 'docx') + return 'doc' + + return item + }) + + return res.map(item => item.toUpperCase()).join(locale === 'en' ? ', ' : '、 ') + })() const ACCEPTS = supportTypes.map((ext: string) => `.${ext}`) const fileUploadConfig = useMemo(() => fileUploadConfigResponse ?? { file_size_limit: 15, @@ -230,7 +262,7 @@ const FileUploader = ({
{t('datasetCreation.stepOne.uploader.tip', { size: fileUploadConfig.file_size_limit, - supportTypes: supportTypes.map(item => item.toUpperCase()).join(locale === 'en' ? ', ' : '、 '), + supportTypes: supportTypesShowNames, })}
{dragging &&
}