From 348c956b2a3968d694a5b6c59eb1f1f60f879687 Mon Sep 17 00:00:00 2001 From: "hong.yang" Date: Thu, 12 Oct 2023 17:14:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=86=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E6=B7=BB=E5=8A=A0=E5=88=B0=E9=85=8D=E7=BD=AE=E4=B8=AD?= =?UTF-8?q?=EF=BC=8C=E5=85=81=E8=AE=B8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-room-ui/example/main.js | 2 ++ data-room-ui/packages/SourceList/index.vue | 23 +++++++++------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/data-room-ui/example/main.js b/data-room-ui/example/main.js index e8992fcc..95fe26be 100644 --- a/data-room-ui/example/main.js +++ b/data-room-ui/example/main.js @@ -56,6 +56,8 @@ registerConfig( '--bs-el-color-primary-active': '64, 158, 255', // 主要激活 => rgba(64, 158, 255, 1) = #409EFF '--bs-el-border': 'transparent' // 边框颜色 }, + // 允许上传的资源库文件类型 + sourceExtends: ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg', 'webp', 'ico', 'xls', 'xlsx', 'csv'], // datasetAuth: ['unAdd', 'unEdit', 'unDelete'], // 数据集按钮权限 新增 编辑 删除 // datasetTypeList: ['original', 'custom', 'http'], // customPlots: [], diff --git a/data-room-ui/packages/SourceList/index.vue b/data-room-ui/packages/SourceList/index.vue index 56b88322..20f70f0d 100644 --- a/data-room-ui/packages/SourceList/index.vue +++ b/data-room-ui/packages/SourceList/index.vue @@ -203,6 +203,7 @@ export default { upLoadUrl: window.BS_CONFIG?.httpConfigs?.baseURL + '/bigScreen/file/upload', searchKey: '', extend: '', + sourceExtends: window.BS_CONFIG?.sourceExtends || [], options: [], list: [], fileUploadParam: {}, @@ -215,7 +216,7 @@ export default { otherExtends: { video: ['mp4', 'avi', 'mov', 'wmv', 'flv', 'f4v', 'rmvb', 'rm', '3gp', 'dat', 'ts', 'mts', 'vob'], audio: ['mp3', 'wav', 'wma', 'ogg', 'aac', 'flac', 'ape', 'm4a', 'm4r', 'amr', 'ac3'], - excel: ['xls', 'xlsx'], + excel: ['xls', 'xlsx', 'csv'], word: ['doc', 'docx'], ppt: ['ppt', 'pptx'], pdf: ['pdf'] @@ -270,14 +271,13 @@ export default { }) }, beforeUpload(file) { - const isImage = file.type.startsWith('image/') - const isVideo = file.type.startsWith('video/') - const isValidFileType = isImage || isVideo - + // 获取文件后缀 + const extension = file.name.split('.').pop() + // 判断文件类型是否符合要求 + const isValidFileType = this.sourceExtends.includes(extension) if (!isValidFileType) { - this.$message.error('只能上传图片或视频文件') + this.$message.error('不支持的文件类型:' + extension) } - return isValidFileType }, uploadSuccess(response, file, fileList) { @@ -295,13 +295,8 @@ export default { } }, getOptions() { - this.$dataRoomAxios.get('/bigScreen/file/getAllFileSuffix').then((data) => { - this.options = [] - this.options.push({label: '全部', value: ''}) - // 过滤data的空数据 - data = data.filter((item) => item) - data.forEach((item) => this.options.push({label: item, value: item})) - }) + this.options.push({label: '全部', value: ''}) + this.sourceExtends.forEach((ext) => this.options.push({label: ext, value: ext})) }, getDataList() { this.loading = true