mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-19 15:09:11 +08:00
fix: update show names for supported file types of xlsx and docx (#3091)
This commit is contained in:
parent
da998d09d7
commit
7cc0d47322
@ -49,38 +49,20 @@ const FileUploader = ({
|
|||||||
const { data: supportFileTypesResponse } = useSWR({ url: '/files/support-type' }, fetchSupportFileTypes)
|
const { data: supportFileTypesResponse } = useSWR({ url: '/files/support-type' }, fetchSupportFileTypes)
|
||||||
const supportTypes = supportFileTypesResponse?.allowed_extensions || []
|
const supportTypes = supportFileTypesResponse?.allowed_extensions || []
|
||||||
const supportTypesShowNames = (() => {
|
const supportTypesShowNames = (() => {
|
||||||
let res = [...supportTypes]
|
const extensionMap: { [key: string]: string } = {
|
||||||
if (res.includes('markdown') && res.includes('md'))
|
md: 'markdown',
|
||||||
res = res.filter(item => item !== 'md')
|
pptx: 'pptx',
|
||||||
|
htm: 'html',
|
||||||
|
xlsx: 'xlsx',
|
||||||
|
docx: 'docx',
|
||||||
|
}
|
||||||
|
|
||||||
if (res.includes('pptx') && res.includes('ppt'))
|
return [...supportTypes]
|
||||||
res = res.filter(item => item !== 'ppt')
|
.map(item => extensionMap[item] || item) // map to standardized extension
|
||||||
|
.map(item => item.toLowerCase()) // convert to lower case
|
||||||
if (res.includes('html') && res.includes('htm'))
|
.filter((item, index, self) => self.indexOf(item) === index) // remove duplicates
|
||||||
res = res.filter(item => item !== 'htm')
|
.map(item => item.toUpperCase()) // convert to upper case
|
||||||
|
.join(locale !== LanguagesSupported[1] ? ', ' : '、 ')
|
||||||
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
|
|
||||||
})
|
|
||||||
res = res.map(item => item.toLowerCase())
|
|
||||||
res = res.filter((item, index, self) => self.indexOf(item) === index)
|
|
||||||
|
|
||||||
return res.map(item => item.toUpperCase()).join(locale !== LanguagesSupported[1] ? ', ' : '、 ')
|
|
||||||
})()
|
})()
|
||||||
const ACCEPTS = supportTypes.map((ext: string) => `.${ext}`)
|
const ACCEPTS = supportTypes.map((ext: string) => `.${ext}`)
|
||||||
const fileUploadConfig = useMemo(() => fileUploadConfigResponse ?? {
|
const fileUploadConfig = useMemo(() => fileUploadConfigResponse ?? {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user