Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
biz.qingxiao.com
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxuelai
biz.qingxiao.com
Commits
d128869d
Commit
d128869d
authored
Nov 27, 2019
by
wangxuelai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
''
parent
da7b3057
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
65 additions
and
7 deletions
+65
-7
index.html
index.html
+1
-1
errorcode.js
src/common/errorcode.js
+4
-0
UploadCourseware.js
src/components/UploadCourseware.js
+1
-1
VideoPlay.js
src/components/VideoPlay.js
+2
-2
coursemateria.js
src/models/coursemateria.js
+27
-1
index.js
src/pages/coursemateria/index.js
+13
-0
uploader.js
src/services/uploader.js
+15
-1
request.js
src/utils/request.js
+2
-1
No files found.
index.html
View file @
d128869d
...
...
@@ -17,6 +17,6 @@
</head>
<body>
<div
id=
"root"
></div>
<script
src=
"dist/main.js?1574844
291005
"
charset=
"utf-8"
></script>
<script
src=
"dist/main.js?1574844
931742
"
charset=
"utf-8"
></script>
</body>
</html>
\ No newline at end of file
src/common/errorcode.js
View file @
d128869d
...
...
@@ -524,6 +524,10 @@ export default {
cn
:
'网络请求错误,请检查您的网络'
,
en
:
'网络请求错误,请检查您的网络'
,
},
100001
:
{
cn
:
'网络请求错误,请检查您的网络'
,
en
:
'网络请求错误,请检查您的网络'
,
},
3360
:
{
cn
:
'您的操作过于频繁,请1小时后再试'
,
en
:
'please wait a moment try again in an hour'
,
...
...
src/components/UploadCourseware.js
View file @
d128869d
...
...
@@ -186,7 +186,7 @@ class UploadCourseware extends React.Component {
<
/div
>
<
div
className
=
{
pageStyle
.
uploadbottom
}
>
<
div
className
=
{
pageStyle
.
left
}
>
<
div
className
=
{
pageStyle
.
uploaddesc
}
>
PPT
/
PPTX
/
PDF
,大小≦
**
MB
<
/div
>
<
div
className
=
{
pageStyle
.
uploaddesc
}
>
PPT
/
PPTX
/
PDF
,大小≦
40
MB
<
/div
>
<
div
className
=
{
pageStyle
.
uploaddesc
}
>
MOV
/
MP4
格式,大小≦
**
MB
<
/div
>
<
/div
>
<
div
className
=
{
pageStyle
.
right
}
>
...
...
src/components/VideoPlay.js
View file @
d128869d
...
...
@@ -2,7 +2,7 @@ import React from 'react';
import
{
Icon
}
from
'antd'
;
import
{
Player
}
from
'video-react'
;
import
componentStyle
from
'./VideoPlay.less'
;
import
{
videoorigin
}
from
'../utils/index'
;
import
{
ossVideofy
}
from
'../utils/index'
;
class
VideoPlay
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -29,7 +29,7 @@ class VideoPlay extends React.Component {
<
div
className
=
{
`
${
componentStyle
.
VideoPlayBox
}
VideoPlayBox`
}
>
<
Icon
type
=
"close-circle"
className
=
{
componentStyle
.
closeIcon
}
onClick
=
{
closeVideoPlay
}
/
>
<
Player
className
=
{
componentStyle
.
videoitem
}
>
<
source
src
=
{
videoorigin
(
src
)}
/
>
<
source
src
=
{
ossVideofy
(
src
)}
/
>
<
/Player
>
<
/div
>
);
...
...
src/models/coursemateria.js
View file @
d128869d
...
...
@@ -29,6 +29,7 @@ export default {
type
:
0
,
// 1 ppt和pdf 2 视频 录音 3 图片
show
:
false
,
},
progressRate
:
0
,
},
subscriptions
:
{
setup
({
dispatch
,
history
})
{
// eslint-disable-line
...
...
@@ -62,6 +63,7 @@ export default {
data
:
transformData
,
},
});
yield
call
(
uploadMateriaLoading
);
}
},
*
fileConvertQuery
({
payload
},
{
call
,
put
,
select
})
{
...
...
@@ -97,6 +99,7 @@ export default {
},
});
}
else
{
yield
call
(
uploadMateriaLoading
);
yield
put
({
type
:
'webapp/errorrequestresolve'
,
payload
:
{
...
...
@@ -154,6 +157,7 @@ export default {
const
{
files
,
successCallBack
,
progressCallBack
,
}
=
payload
;
const
file
=
files
?
files
[
0
]
:
null
;
if
(
!
file
)
{
...
...
@@ -198,10 +202,20 @@ export default {
params
=
{
type
:
2
,
token
:
userInfo
.
token
,
schoolId
:
sid
};
break
;
case
4
:
// ppt
if
(
file
.
size
>
40
*
1024
*
1024
)
{
yield
call
(
uploadMateriaLoading
);
message
.
error
(
'ppt的大小不能超过【40MB】,请重新上传'
,
1
);
return
;
}
ajax
=
uploader
.
uploadVideoSignature
;
params
=
{
type
:
3
,
token
:
userInfo
.
token
,
schoolId
:
sid
};
break
;
case
5
:
// pdf
if
(
file
.
size
>
40
*
1024
*
1024
)
{
yield
call
(
uploadMateriaLoading
);
message
.
error
(
'pdf的大小不能超过【40MB】,请重新上传'
,
1
);
return
;
}
ajax
=
uploader
.
uploadVideoSignature
;
params
=
{
type
:
4
,
token
:
userInfo
.
token
,
schoolId
:
sid
};
break
;
...
...
@@ -222,6 +236,7 @@ export default {
signature
,
successCallBack
,
file
,
progressCallBack
,
},
});
}
else
{
...
...
@@ -254,11 +269,13 @@ export default {
}
},
*
uploadFile
({
payload
},
{
call
,
put
})
{
const
that
=
this
;
const
{
signature
,
file
,
successCallBack
,
duration
,
progressCallBack
,
}
=
payload
;
const
filename
=
`
${
signature
.
dir
}${
getRandomFilename
(
file
.
name
)}
`
;
const
{
name
,
size
,
type
:
fileType
}
=
file
;
...
...
@@ -269,8 +286,17 @@ export default {
signature
:
signature
.
signature
,
file
,
url
:
signature
.
host
,
callback
:
signature
.
callback
,
};
const
uploadFileData
=
yield
call
(
uploader
.
uploadImg
,
params
);
const
uploadFileData
=
yield
call
(
uploader
.
uploadImg
,
params
,
(
res
)
=>
{
progressCallBack
(
res
);
});
const
{
code
}
=
uploadFileData
;
if
(
code
==
100001
)
{
yield
call
(
uploadMateriaLoading
);
message
.
error
(
'请求超时,请重试'
,
1
);
return
;
}
if
(
getFileType
(
fileType
).
filetype
==
4
)
{
yield
put
({
type
:
'fileTransForm'
,
...
...
src/pages/coursemateria/index.js
View file @
d128869d
...
...
@@ -38,6 +38,15 @@ class StaticCenter extends React.Component {
successCallBack
()
{
document
.
getElementById
(
'uploadMateria'
).
value
=
''
;
},
progressCallBack
(
res
)
{
console
.
log
(
res
);
dispatch
({
type
:
'coursemateria/updateState'
,
payload
:
{
progressRate
:
((
res
.
loaded
/
res
.
total
)
*
100
).
toFixed
(
0
),
},
});
},
},
});
}
...
...
@@ -185,9 +194,11 @@ class StaticCenter extends React.Component {
materiaListTotal
,
queryParams
,
tabIndex
,
progressRate
,
}
=
this
.
props
;
return
(
<
div
className
=
{
pageStyle
.
container
}
>
{
progressRate
}
%
<
div
className
=
{
pageStyle
.
tabbox
}
>
<
div
className
=
{
`
${
pageStyle
.
tabitem
}
${
tabIndex
==
0
?
pageStyle
.
active
:
''
}
`
}
onClick
=
{()
=>
this
.
tabClick
(
''
,
0
)}
>
全部
<
/div
>
<
div
className
=
{
`
${
pageStyle
.
tabitem
}
${
tabIndex
==
1
?
pageStyle
.
active
:
''
}
`
}
onClick
=
{()
=>
this
.
tabClick
(
1
,
1
)}
>
图片
<
/div
>
...
...
@@ -277,12 +288,14 @@ function mapStateToProps(state) {
materiaListTotal
,
queryParams
,
tabIndex
,
progressRate
,
}
=
state
.
coursemateria
;
return
{
materiaList
,
materiaListTotal
,
queryParams
,
tabIndex
,
progressRate
,
};
}
export
default
connect
(
mapStateToProps
)(
StaticCenter
);
...
...
src/services/uploader.js
View file @
d128869d
...
...
@@ -59,7 +59,7 @@ export function uploadImageSignature({ type, token, schoolId }) {
},
});
}
export
function
uploadImg
(
params
)
{
export
function
uploadImg
(
params
,
progressCallback
)
{
const
{
OSSAccessKeyId
,
file
,
...
...
@@ -67,12 +67,15 @@ export function uploadImg(params) {
policy
,
signature
,
url
,
callback
,
}
=
params
;
const
formData
=
new
FormData
();
formData
.
append
(
'key'
,
key
);
formData
.
append
(
'policy'
,
policy
);
formData
.
append
(
'OSSAccessKeyId'
,
OSSAccessKeyId
);
formData
.
append
(
'signature'
,
signature
);
formData
.
append
(
'callback'
,
callback
);
formData
.
append
(
'success_action_status'
,
200
);
formData
.
append
(
'file'
,
file
);
return
request
({
url
:
params
.
url
,
...
...
@@ -81,5 +84,16 @@ export function uploadImg(params) {
'Content-Type'
:
'multipart/form-data'
,
},
data
:
formData
,
timeout
:
60
*
1000
*
30
,
retry
:
0
,
onUploadProgress
(
progressEvent
)
{
// 原生获取上传进度的事件
if
(
progressEvent
.
lengthComputable
)
{
// 属性lengthComputable主要表明总共需要完成的工作量和已经完成的工作是否可以被测量
// 如果lengthComputable为false,就获取不到progressEvent.total和progressEvent.loaded
if
(
progressCallback
&&
(
typeof
progressCallback
==
'function'
))
{
progressCallback
(
progressEvent
);
}
}
},
});
}
src/utils/request.js
View file @
d128869d
...
...
@@ -24,6 +24,7 @@ axios.interceptors.request.use((config) => {
// Do something with request error
return
Promise
.
reject
(
error
);
});
// axios.defaults.timeout = 30000;
axios
.
defaults
.
timeout
=
30000
;
axios
.
defaults
.
retry
=
1
;
axios
.
defaults
.
retryDelay
=
3000
;
...
...
@@ -86,7 +87,7 @@ export default function request(options) {
})
.
catch
(
err
=>
{
return
{
code
:
10000
0
,
code
:
10000
1
,
errordata
:
err
,
message
:
'error'
}
...
...
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