Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xiaomai-cloud-class-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiaomai-cloud-class
xiaomai-cloud-class-web
Commits
639cece4
Commit
639cece4
authored
Dec 25, 2020
by
zhangleyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:处理上传文件的限制
parent
bd2043ff
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
90 additions
and
88 deletions
+90
-88
src/bu-components/NonCompliantFileModal.jsx
+1
-1
src/bu-components/SelectPrepareFileModal.jsx
+20
-20
src/common/constants/academic/lessonEnum.js
+14
-14
src/domains/resource-disk/constants.ts
+16
-16
src/modules/course-manage/components/AddLiveIntro.jsx
+5
-1
src/modules/course-manage/components/LiveCourseList.jsx
+1
-1
src/modules/prepare-lesson/components/FolderList.jsx
+1
-2
src/modules/prepare-lesson/modal/NonCompliantFileModal.jsx
+1
-1
src/modules/prepare-lesson/modal/SelectPrepareFileModal.jsx
+13
-14
src/modules/resource-disk/components/OperateArea.jsx
+18
-18
No files found.
src/bu-components/NonCompliantFileModal.jsx
View file @
639cece4
...
...
@@ -55,7 +55,7 @@ class NonCompliantFileModal extends React.Component {
<
div
className=
"tips"
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
className=
"tips__text"
>
支持上传 Word(100M以内)、Excel(10M以内)、PPT(100M以内)、PDF(100M以内)、图片(50M以内)、音频(50M以内)、视频(500M以内)。
支持上传:Word(100M以内)、Excel(10M以内)、PPT(100M以内)、PDF(100M以内)、图片(5M以内)、音频(20M以内)、视频(500M以内)
</
span
>
</
div
>
</
Modal
>
...
...
src/bu-components/SelectPrepareFileModal.jsx
View file @
639cece4
...
...
@@ -18,8 +18,9 @@ import { getFileTypeByName } from '@/domains/resource-disk/utils';
import
{
DEFAULT_SIZE_UNIT
,
FILE_TYPE_ICON_MAP
,
FILR_VERIFY_MAP
,
NON_COMPLIANT_FILE_MAP
,
LOCAL
_FILE_TYPE_MAP
SUPPORT
_FILE_TYPE_MAP
}
from
"@/domains/resource-disk/constants"
;
import
UploadProgressModal
from
'@/bu-components/UploadProgressModal'
;
...
...
@@ -48,8 +49,8 @@ const FOLDERLIST_URL_MAP = {
};
// 支持本地上传的文件类型
const
localFileTypeMap
=
LOCAL
_FILE_TYPE_MAP
.
join
(
','
);
const
localFileTypeMap
=
SUPPORT
_FILE_TYPE_MAP
.
join
(
','
);
const
FileVerifyMap
=
FILR_VERIFY_MAP
;
// 合法的文件名后缀
const
FILE_SUFFIX_LIST
=
[
'docx'
,
'doc'
,
'ppt'
,
'pptx'
,
'pdf'
,
'xlsx'
,
'xls'
,
'jpg'
,
'jpeg'
,
'png'
,
'mp3'
,
'mp4'
];
// 禁止选择的文件类型
...
...
@@ -323,23 +324,22 @@ class SelectPrepareFileModal extends React.Component {
const
_fileList
=
[...
fileList
];
_fileList
.
map
((
file
,
index
)
=>
{
let
{
size
,
type
,
name
}
=
file
;
console
.
log
(
'file'
,
file
);
if
(
!
type
)
{
type
=
getFileTypeByName
(
name
);
}
if
(
type
.
indexOf
(
'image'
)
>
-
1
&&
size
>
5
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
type
.
indexOf
(
'audio'
)
>
-
1
&&
size
>
20
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
type
.
indexOf
(
'video'
)
>
-
1
&&
size
>
500
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
localFileTypeMap
.
indexOf
(
type
)
>
-
1
&&
size
>
100
*
DEFAULT_SIZE_UNIT
)
{
// if (!type) {
// type = getFileTypeByName(name);
// }
// if (type.indexOf('image') > -1 && size > 5 * DEFAULT_SIZE_UNIT) {
// nonCompliantFileList.push(file);
// _fileList.splice(index, 1);
// }
// if (type.indexOf('audio') > -1 && size > 20 * DEFAULT_SIZE_UNIT) {
// nonCompliantFileList.push(file);
// _fileList.splice(index, 1);
// }
// if (type.indexOf('video') > -1 && size > 500 * DEFAULT_SIZE_UNIT) {
// nonCompliantFileList.push(file);
// _fileList.splice(index, 1);
// }
if
(
localFileTypeMap
.
indexOf
(
type
)
>
-
1
&&
size
>
FileVerifyMap
[
type
].
maxSize
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
...
...
src/common/constants/academic/lessonEnum.js
View file @
639cece4
...
...
@@ -42,11 +42,11 @@ const LocalFileType = [
const
FileVerifyMap
=
{
"application/msword"
:
{
type
:
"word"
,
maxSize
:
10
maxSize
:
10
0
},
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
:
{
type
:
"word"
,
maxSize
:
10
maxSize
:
10
0
},
"text/csv"
:
{
type
:
"Excel"
,
...
...
@@ -66,51 +66,51 @@ const FileVerifyMap = {
},
"application/vnd.ms-powerpoint"
:
{
type
:
"PPT"
,
maxSize
:
2
0
maxSize
:
10
0
},
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
:
{
type
:
"PPT"
,
maxSize
:
2
0
maxSize
:
10
0
},
"application/pdf"
:
{
type
:
"PDF"
,
maxSize
:
5
0
maxSize
:
10
0
},
"application/wps-office.pdf"
:
{
type
:
"PDF"
,
maxSize
:
5
0
maxSize
:
10
0
},
"image/jpeg"
:
{
type
:
"JPG"
,
maxSize
:
10
maxSize
:
5
},
"image/png"
:
{
type
:
"JPG"
,
maxSize
:
10
maxSize
:
5
},
"image/jpg"
:
{
type
:
"JPG"
,
maxSize
:
10
maxSize
:
5
},
"image/gif"
:
{
type
:
"GIF"
,
maxSize
:
10
maxSize
:
5
},
"audio/mpeg"
:
{
type
:
"MP3"
,
maxSize
:
5
0
maxSize
:
2
0
},
"audio/mp3"
:
{
type
:
"MP3"
,
maxSize
:
5
0
maxSize
:
2
0
},
"audio/mp4"
:
{
type
:
"MP4"
,
maxSize
:
50
maxSize
:
50
0
},
"video/mp4"
:
{
type
:
"MP4"
,
maxSize
:
50
maxSize
:
50
0
}
};
...
...
src/domains/resource-disk/constants.ts
View file @
639cece4
/*
* @Author: 吴文洁
* @Date: 2020-08-20 09:21:40
* @LastEditors:
吴文洁
* @LastEditTime: 2020-1
0-13 14:55:24
* @LastEditors:
zhangleyuan
* @LastEditTime: 2020-1
2-25 10:48:15
* @Description:
* @Copyright: 杭州杰竞科技有限公司 版权所有
*/
...
...
@@ -75,11 +75,11 @@ const LOCAL_FILE_TYPE_MAP: string[] = [
const
FILR_VERIFY_MAP
=
{
"application/msword"
:
{
type
:
"word"
,
maxSize
:
10
maxSize
:
10
0
},
"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
:
{
type
:
"word"
,
maxSize
:
10
maxSize
:
10
0
},
"text/csv"
:
{
type
:
"Excel"
,
...
...
@@ -99,51 +99,51 @@ const FILR_VERIFY_MAP = {
},
"application/vnd.ms-powerpoint"
:
{
type
:
"PPT"
,
maxSize
:
2
0
maxSize
:
10
0
},
"application/vnd.openxmlformats-officedocument.presentationml.presentation"
:
{
type
:
"PPT"
,
maxSize
:
2
0
maxSize
:
10
0
},
"application/pdf"
:
{
type
:
"PDF"
,
maxSize
:
5
0
maxSize
:
10
0
},
"application/wps-office.pdf"
:
{
type
:
"PDF"
,
maxSize
:
5
0
maxSize
:
10
0
},
"image/jpeg"
:
{
type
:
"JPG"
,
maxSize
:
10
maxSize
:
5
},
"image/png"
:
{
type
:
"JPG"
,
maxSize
:
10
maxSize
:
5
},
"image/jpg"
:
{
type
:
"JPG"
,
maxSize
:
10
maxSize
:
5
},
"image/gif"
:
{
type
:
"GIF"
,
maxSize
:
10
maxSize
:
5
},
"audio/mpeg"
:
{
type
:
"MP3"
,
maxSize
:
5
0
maxSize
:
2
0
},
"audio/mp3"
:
{
type
:
"MP3"
,
maxSize
:
5
0
maxSize
:
2
0
},
"audio/mp4"
:
{
type
:
"MP4"
,
maxSize
:
50
maxSize
:
50
0
},
"video/mp4"
:
{
type
:
"MP4"
,
maxSize
:
50
maxSize
:
50
0
}
};
...
...
src/modules/course-manage/components/AddLiveIntro.jsx
View file @
639cece4
...
...
@@ -62,7 +62,11 @@ class AddLiveIntro extends React.Component {
}
else
{
// 最多添加九图片
const
{
liveCourseMediaRequests
}
=
this
.
props
.
data
;
if
(
liveCourseMediaRequests
.
length
>
8
)
{
const
list
=
_
.
filter
(
liveCourseMediaRequests
,
(
item
)
=>
{
return
item
.
mediaType
==
"PICTURE"
;
});
if
(
list
.
length
>
8
)
{
message
.
warning
(
"最多添加9张图片"
);
return
;
}
...
...
src/modules/course-manage/components/LiveCourseList.jsx
View file @
639cece4
...
...
@@ -379,7 +379,7 @@ class LiveCourseList extends React.Component {
className=
"icon iconfont default-confirm-icon"
style=
{
{
color
:
"#FFBB54 !important"
}
}
>

;

;
</
span
>
),
});
...
...
src/modules/prepare-lesson/components/FolderList.jsx
View file @
639cece4
...
...
@@ -24,8 +24,7 @@ const DEL_FOLDER_URL_MAP = {
'COMMON'
:
'public/apollo/delCommonFolder'
}
// 支持本地上传的文件类型
const
loaclFileType
=
SupportFileType
.
join
(
','
);
let
count
=
0
;
...
...
src/modules/prepare-lesson/modal/NonCompliantFileModal.jsx
View file @
639cece4
...
...
@@ -55,7 +55,7 @@ class NonCompliantFileModal extends React.Component {
<
div
className=
"tips"
>
<
span
className=
"icon iconfont"
>

</
span
>
<
span
className=
"tips__text"
>
支持上传 Word(100M以内)、Excel(10M以内)、PPT(100M以内)、PDF(100M以内)、图片(50M以内)、音频(50M以内)、视频(500M以内)。
支持上传:Word(100M以内)、Excel(10M以内)、PPT(100M以内)、PDF(100M以内)、图片(5M以内)、音频(20M以内)、视频(500M以内)
</
span
>
</
div
>
</
Modal
>
...
...
src/modules/prepare-lesson/modal/SelectPrepareFileModal.jsx
View file @
639cece4
...
...
@@ -46,7 +46,6 @@ const FOLDERLIST_URL_MAP = {
// 支持本地上传的文件类型
const
supportFileType
=
SupportFileType
.
join
(
','
);
const
localFileType
=
LocalFileType
.
join
(
','
);
// 合法的文件名后缀
const
FILE_SUFFIX_LIST
=
[
'docx'
,
'doc'
,
'ppt'
,
'pptx'
,
'pdf'
,
'xlsx'
,
'xls'
,
'jpg'
,
'jpeg'
,
'png'
,
'mp3'
,
'mp4'
];
...
...
@@ -327,19 +326,19 @@ class SelectPrepareFileModal extends React.Component {
if
(
!
type
)
{
type
=
getFileTypeByName
(
name
);
}
if
(
type
.
indexOf
(
'image'
)
>
-
1
&&
size
>
5
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
type
.
indexOf
(
'audio'
)
>
-
1
&&
size
>
20
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
type
.
indexOf
(
'video'
)
>
-
1
&&
size
>
500
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
local
FileType
.
indexOf
(
type
)
>
-
1
&&
size
>
FileVerifyMap
[
type
].
maxSize
*
DEFAULT_SIZE_UNIT
)
{
//
if (type.indexOf('image') > -1 && size > 5 * DEFAULT_SIZE_UNIT) {
//
nonCompliantFileList.push(file);
//
_fileList.splice(index, 1);
//
}
//
if (type.indexOf('audio') > -1 && size > 20 * DEFAULT_SIZE_UNIT) {
//
nonCompliantFileList.push(file);
//
_fileList.splice(index, 1);
//
}
//
if (type.indexOf('video') > -1 && size > 500 * DEFAULT_SIZE_UNIT) {
//
nonCompliantFileList.push(file);
//
_fileList.splice(index, 1);
//
}
if
(
support
FileType
.
indexOf
(
type
)
>
-
1
&&
size
>
FileVerifyMap
[
type
].
maxSize
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
...
...
src/modules/resource-disk/components/OperateArea.jsx
View file @
639cece4
...
...
@@ -13,7 +13,7 @@ import _ from 'underscore';
import
Service
from
'@/common/js/service'
;
import
{
getEllipsText
}
from
'@/domains/basic-domain/utils'
;
import
{
DEFAULT_SIZE_UNIT
,
LOCAL_FILE_TYPE_MAP
}
from
'@/domains/resource-disk/constants'
;
import
{
DEFAULT_SIZE_UNIT
,
LOCAL_FILE_TYPE_MAP
,
FILR_VERIFY_MAP
,
SUPPORT_FILE_TYPE_MAP
}
from
'@/domains/resource-disk/constants'
;
import
{
getFileTypeByName
}
from
'@/domains/resource-disk/utils'
;
import
UploadProgressModal
from
'@/bu-components/UploadProgressModal'
;
...
...
@@ -29,7 +29,10 @@ const DEL_FOLDER_URL_MAP = {
'COMMON'
:
'public/hadesStore/delFolder'
}
// 支持本地上传的文件类型
const
localFileTypeMap
=
LOCAL_FILE_TYPE_MAP
.
join
(
','
);
// 支持本地上传的文件类型
const
localFileTypeMap
=
SUPPORT_FILE_TYPE_MAP
.
join
(
','
);
const
FileVerifyMap
=
FILR_VERIFY_MAP
;
let
count
=
0
;
class
OperateArea
extends
React
.
Component
{
...
...
@@ -114,30 +117,27 @@ class OperateArea extends React.Component {
// 准备上传
handleUpload
=
(
event
)
=>
{
const
fileList
=
event
.
target
.
files
;
debugger
// 判断文件的大小是否超出了限制
const
nonCompliantFileList
=
[];
const
_fileList
=
[...
fileList
];
_fileList
.
map
((
file
,
index
)
=>
{
debugger
let
{
size
,
type
,
name
}
=
file
;
if
(
!
type
)
{
type
=
getFileTypeByName
(
name
);
}
if
(
type
.
indexOf
(
'image'
)
>
-
1
&&
size
>
50
*
DEFAULT_SIZE_UNIT
)
{
debugger
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
type
.
indexOf
(
'audio'
)
>
-
1
&&
size
>
50
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
type
.
indexOf
(
'video'
)
>
-
1
&&
size
>
500
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
if
(
localFileTypeMap
.
indexOf
(
type
)
>
-
1
&&
size
>
100
*
DEFAULT_SIZE_UNIT
)
{
// if (type.indexOf('image') > -1 && size > 50 * DEFAULT_SIZE_UNIT) {
// nonCompliantFileList.push(file);
// _fileList.splice(index, 1);
// }
// if (type.indexOf('audio') > -1 && size > 50 * DEFAULT_SIZE_UNIT) {
// nonCompliantFileList.push(file);
// _fileList.splice(index, 1);
// }
// if (type.indexOf('video') > -1 && size > 500 * DEFAULT_SIZE_UNIT) {
// nonCompliantFileList.push(file);
// _fileList.splice(index, 1);
// }
if
(
localFileTypeMap
.
indexOf
(
type
)
>
-
1
&&
size
>
FileVerifyMap
[
type
].
maxSize
*
DEFAULT_SIZE_UNIT
)
{
nonCompliantFileList
.
push
(
file
);
_fileList
.
splice
(
index
,
1
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment