Commit d128869d authored by wangxuelai's avatar wangxuelai

''

parent da7b3057
...@@ -17,6 +17,6 @@ ...@@ -17,6 +17,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="dist/main.js?1574844291005" charset="utf-8"></script> <script src="dist/main.js?1574844931742" charset="utf-8"></script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -524,6 +524,10 @@ export default { ...@@ -524,6 +524,10 @@ export default {
cn: '网络请求错误,请检查您的网络', cn: '网络请求错误,请检查您的网络',
en: '网络请求错误,请检查您的网络', en: '网络请求错误,请检查您的网络',
}, },
100001: {
cn: '网络请求错误,请检查您的网络',
en: '网络请求错误,请检查您的网络',
},
3360: { 3360: {
cn: '您的操作过于频繁,请1小时后再试', cn: '您的操作过于频繁,请1小时后再试',
en: 'please wait a moment try again in an hour', en: 'please wait a moment try again in an hour',
......
...@@ -186,7 +186,7 @@ class UploadCourseware extends React.Component { ...@@ -186,7 +186,7 @@ class UploadCourseware extends React.Component {
</div> </div>
<div className={pageStyle.uploadbottom}> <div className={pageStyle.uploadbottom}>
<div className={pageStyle.left}> <div className={pageStyle.left}>
<div className={pageStyle.uploaddesc}>PPT/PPTX/PDF,大小≦**MB</div> <div className={pageStyle.uploaddesc}>PPT/PPTX/PDF,大小≦40MB</div>
<div className={pageStyle.uploaddesc}>MOV/MP4格式,大小≦**MB</div> <div className={pageStyle.uploaddesc}>MOV/MP4格式,大小≦**MB</div>
</div> </div>
<div className={pageStyle.right}> <div className={pageStyle.right}>
......
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import { Icon } from 'antd'; import { Icon } from 'antd';
import { Player } from 'video-react'; import { Player } from 'video-react';
import componentStyle from './VideoPlay.less'; import componentStyle from './VideoPlay.less';
import { videoorigin } from '../utils/index'; import { ossVideofy } from '../utils/index';
class VideoPlay extends React.Component { class VideoPlay extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -29,7 +29,7 @@ class VideoPlay extends React.Component { ...@@ -29,7 +29,7 @@ class VideoPlay extends React.Component {
<div className={`${componentStyle.VideoPlayBox} VideoPlayBox`}> <div className={`${componentStyle.VideoPlayBox} VideoPlayBox`}>
<Icon type="close-circle" className={componentStyle.closeIcon} onClick={closeVideoPlay} /> <Icon type="close-circle" className={componentStyle.closeIcon} onClick={closeVideoPlay} />
<Player className={componentStyle.videoitem}> <Player className={componentStyle.videoitem}>
<source src={videoorigin(src)} /> <source src={ossVideofy(src)} />
</Player> </Player>
</div> </div>
); );
......
...@@ -29,6 +29,7 @@ export default { ...@@ -29,6 +29,7 @@ export default {
type: 0, // 1 ppt和pdf 2 视频 录音 3 图片 type: 0, // 1 ppt和pdf 2 视频 录音 3 图片
show: false, show: false,
}, },
progressRate: 0,
}, },
subscriptions: { subscriptions: {
setup({ dispatch, history }) { // eslint-disable-line setup({ dispatch, history }) { // eslint-disable-line
...@@ -62,6 +63,7 @@ export default { ...@@ -62,6 +63,7 @@ export default {
data: transformData, data: transformData,
}, },
}); });
yield call(uploadMateriaLoading);
} }
}, },
* fileConvertQuery({ payload }, { call, put, select }) { * fileConvertQuery({ payload }, { call, put, select }) {
...@@ -97,6 +99,7 @@ export default { ...@@ -97,6 +99,7 @@ export default {
}, },
}); });
} else { } else {
yield call(uploadMateriaLoading);
yield put({ yield put({
type: 'webapp/errorrequestresolve', type: 'webapp/errorrequestresolve',
payload: { payload: {
...@@ -154,6 +157,7 @@ export default { ...@@ -154,6 +157,7 @@ export default {
const { const {
files, files,
successCallBack, successCallBack,
progressCallBack,
} = payload; } = payload;
const file = files ? files[0] : null; const file = files ? files[0] : null;
if (!file) { if (!file) {
...@@ -198,10 +202,20 @@ export default { ...@@ -198,10 +202,20 @@ export default {
params = { type: 2, token: userInfo.token, schoolId: sid }; params = { type: 2, token: userInfo.token, schoolId: sid };
break; break;
case 4: // ppt case 4: // ppt
if (file.size > 40 * 1024 * 1024) {
yield call(uploadMateriaLoading);
message.error('ppt的大小不能超过【40MB】,请重新上传', 1);
return;
}
ajax = uploader.uploadVideoSignature; ajax = uploader.uploadVideoSignature;
params = { type: 3, token: userInfo.token, schoolId: sid }; params = { type: 3, token: userInfo.token, schoolId: sid };
break; break;
case 5: // pdf case 5: // pdf
if (file.size > 40 * 1024 * 1024) {
yield call(uploadMateriaLoading);
message.error('pdf的大小不能超过【40MB】,请重新上传', 1);
return;
}
ajax = uploader.uploadVideoSignature; ajax = uploader.uploadVideoSignature;
params = { type: 4, token: userInfo.token, schoolId: sid }; params = { type: 4, token: userInfo.token, schoolId: sid };
break; break;
...@@ -222,6 +236,7 @@ export default { ...@@ -222,6 +236,7 @@ export default {
signature, signature,
successCallBack, successCallBack,
file, file,
progressCallBack,
}, },
}); });
} else { } else {
...@@ -254,11 +269,13 @@ export default { ...@@ -254,11 +269,13 @@ export default {
} }
}, },
* uploadFile({ payload }, { call, put }) { * uploadFile({ payload }, { call, put }) {
const that = this;
const { const {
signature, signature,
file, file,
successCallBack, successCallBack,
duration, duration,
progressCallBack,
} = payload; } = payload;
const filename = `${signature.dir}${getRandomFilename(file.name)}`; const filename = `${signature.dir}${getRandomFilename(file.name)}`;
const { name, size, type: fileType } = file; const { name, size, type: fileType } = file;
...@@ -269,8 +286,17 @@ export default { ...@@ -269,8 +286,17 @@ export default {
signature: signature.signature, signature: signature.signature,
file, file,
url: signature.host, 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) { if (getFileType(fileType).filetype == 4) {
yield put({ yield put({
type: 'fileTransForm', type: 'fileTransForm',
......
...@@ -38,6 +38,15 @@ class StaticCenter extends React.Component { ...@@ -38,6 +38,15 @@ class StaticCenter extends React.Component {
successCallBack() { successCallBack() {
document.getElementById('uploadMateria').value = ''; 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 { ...@@ -185,9 +194,11 @@ class StaticCenter extends React.Component {
materiaListTotal, materiaListTotal,
queryParams, queryParams,
tabIndex, tabIndex,
progressRate,
} = this.props; } = this.props;
return ( return (
<div className={pageStyle.container}> <div className={pageStyle.container}>
{progressRate}%
<div className={pageStyle.tabbox}> <div className={pageStyle.tabbox}>
<div className={`${pageStyle.tabitem} ${tabIndex == 0 ? pageStyle.active : ''}`} onClick={() => this.tabClick('', 0)}>全部</div> <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> <div className={`${pageStyle.tabitem} ${tabIndex == 1 ? pageStyle.active : ''}`} onClick={() => this.tabClick(1, 1)}>图片</div>
...@@ -277,12 +288,14 @@ function mapStateToProps(state) { ...@@ -277,12 +288,14 @@ function mapStateToProps(state) {
materiaListTotal, materiaListTotal,
queryParams, queryParams,
tabIndex, tabIndex,
progressRate,
} = state.coursemateria; } = state.coursemateria;
return { return {
materiaList, materiaList,
materiaListTotal, materiaListTotal,
queryParams, queryParams,
tabIndex, tabIndex,
progressRate,
}; };
} }
export default connect(mapStateToProps)(StaticCenter); export default connect(mapStateToProps)(StaticCenter);
......
...@@ -59,7 +59,7 @@ export function uploadImageSignature({ type, token, schoolId }) { ...@@ -59,7 +59,7 @@ export function uploadImageSignature({ type, token, schoolId }) {
}, },
}); });
} }
export function uploadImg(params) { export function uploadImg(params, progressCallback) {
const { const {
OSSAccessKeyId, OSSAccessKeyId,
file, file,
...@@ -67,12 +67,15 @@ export function uploadImg(params) { ...@@ -67,12 +67,15 @@ export function uploadImg(params) {
policy, policy,
signature, signature,
url, url,
callback,
} = params; } = params;
const formData = new FormData(); const formData = new FormData();
formData.append('key', key); formData.append('key', key);
formData.append('policy', policy); formData.append('policy', policy);
formData.append('OSSAccessKeyId', OSSAccessKeyId); formData.append('OSSAccessKeyId', OSSAccessKeyId);
formData.append('signature', signature); formData.append('signature', signature);
formData.append('callback', callback);
formData.append('success_action_status', 200);
formData.append('file', file); formData.append('file', file);
return request({ return request({
url: params.url, url: params.url,
...@@ -81,5 +84,16 @@ export function uploadImg(params) { ...@@ -81,5 +84,16 @@ export function uploadImg(params) {
'Content-Type': 'multipart/form-data', 'Content-Type': 'multipart/form-data',
}, },
data: formData, 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);
}
}
},
}); });
} }
...@@ -24,6 +24,7 @@ axios.interceptors.request.use((config) => { ...@@ -24,6 +24,7 @@ axios.interceptors.request.use((config) => {
// Do something with request error // Do something with request error
return Promise.reject(error); return Promise.reject(error);
}); });
// axios.defaults.timeout = 30000;
axios.defaults.timeout = 30000; axios.defaults.timeout = 30000;
axios.defaults.retry = 1; axios.defaults.retry = 1;
axios.defaults.retryDelay = 3000; axios.defaults.retryDelay = 3000;
...@@ -86,7 +87,7 @@ export default function request(options) { ...@@ -86,7 +87,7 @@ export default function request(options) {
}) })
.catch(err => { .catch(err => {
return { return {
code: 100000, code: 100001,
errordata: err, errordata: err,
message: 'error' message: 'error'
} }
......
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