mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
refactor: 根据配置类型限制上传文件格式
This commit is contained in:
parent
119bba030b
commit
56a09d7b2c
|
|
@ -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)"
|
||||
>
|
||||
<el-button text>
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue