Commit bd2043ff by zhangleyuan

feat:处理上传文件的限制

parent 75061134
...@@ -323,15 +323,15 @@ class SelectPrepareFileModal extends React.Component { ...@@ -323,15 +323,15 @@ class SelectPrepareFileModal extends React.Component {
const _fileList = [...fileList]; const _fileList = [...fileList];
_fileList.map((file, index) => { _fileList.map((file, index) => {
let { size, type, name } = file; let { size, type, name } = file;
console.log('file',file);
if (!type) { if (!type) {
type = getFileTypeByName(name); type = getFileTypeByName(name);
} }
if (type.indexOf('image') > -1 && size > 5 * DEFAULT_SIZE_UNIT) {
if (type.indexOf('image') > -1 && size > 50 * DEFAULT_SIZE_UNIT) {
nonCompliantFileList.push(file); nonCompliantFileList.push(file);
_fileList.splice(index, 1); _fileList.splice(index, 1);
} }
if (type.indexOf('audio') > -1 && size > 50 * DEFAULT_SIZE_UNIT) { if (type.indexOf('audio') > -1 && size > 20 * DEFAULT_SIZE_UNIT) {
nonCompliantFileList.push(file); nonCompliantFileList.push(file);
_fileList.splice(index, 1); _fileList.splice(index, 1);
} }
......
...@@ -19,7 +19,7 @@ import Service from '@/common/js/service'; ...@@ -19,7 +19,7 @@ import Service from '@/common/js/service';
import _ from 'underscore'; import _ from 'underscore';
import { import {
DEFAULT_SIZE_UNIT, FileTypeIcon, NonCompliantFileMap, DEFAULT_SIZE_UNIT, FileTypeIcon, NonCompliantFileMap,
DISK_LIST, SupportFileType, LocalFileType DISK_LIST, SupportFileType, LocalFileType,FileVerifyMap
} from "@/common/constants/academic/lessonEnum"; } from "@/common/constants/academic/lessonEnum";
import { getFileTypeByName } from '../components/FolderManage'; import { getFileTypeByName } from '../components/FolderManage';
...@@ -322,16 +322,16 @@ class SelectPrepareFileModal extends React.Component { ...@@ -322,16 +322,16 @@ class SelectPrepareFileModal extends React.Component {
const nonCompliantFileList = []; const nonCompliantFileList = [];
const _fileList = [...fileList]; const _fileList = [...fileList];
_fileList.map((file, index) => { _fileList.map((file, index) => {
console.log('file',file);
let { size, type, name } = file; let { size, type, name } = file;
if (!type) { if (!type) {
type = getFileTypeByName(name); type = getFileTypeByName(name);
} }
if (type.indexOf('image') > -1 && size > 5 * DEFAULT_SIZE_UNIT) {
if (type.indexOf('image') > -1 && size > 50 * DEFAULT_SIZE_UNIT) {
nonCompliantFileList.push(file); nonCompliantFileList.push(file);
_fileList.splice(index, 1); _fileList.splice(index, 1);
} }
if (type.indexOf('audio') > -1 && size > 50 * DEFAULT_SIZE_UNIT) { if (type.indexOf('audio') > -1 && size > 20 * DEFAULT_SIZE_UNIT) {
nonCompliantFileList.push(file); nonCompliantFileList.push(file);
_fileList.splice(index, 1); _fileList.splice(index, 1);
} }
...@@ -339,12 +339,13 @@ class SelectPrepareFileModal extends React.Component { ...@@ -339,12 +339,13 @@ class SelectPrepareFileModal extends React.Component {
nonCompliantFileList.push(file); nonCompliantFileList.push(file);
_fileList.splice(index, 1); _fileList.splice(index, 1);
} }
if (localFileType.indexOf(type) > -1 && size > 100 * DEFAULT_SIZE_UNIT) { if (localFileType.indexOf(type) > -1 && size > FileVerifyMap[type].maxSize * DEFAULT_SIZE_UNIT) {
nonCompliantFileList.push(file); nonCompliantFileList.push(file);
_fileList.splice(index, 1); _fileList.splice(index, 1);
} }
file.key = count++; file.key = count++;
}); });
console.log("nonCompliantFileList",nonCompliantFileList);
// 不符合规则的文件列表 // 不符合规则的文件列表
if (nonCompliantFileList.length > 0) { if (nonCompliantFileList.length > 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment