Commit d128869d authored by wangxuelai's avatar wangxuelai

''

parent da7b3057
......@@ -17,6 +17,6 @@
</head>
<body>
<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>
</html>
\ No newline at end of file
......@@ -524,6 +524,10 @@ export default {
cn: '网络请求错误,请检查您的网络',
en: '网络请求错误,请检查您的网络',
},
100001: {
cn: '网络请求错误,请检查您的网络',
en: '网络请求错误,请检查您的网络',
},
3360: {
cn: '您的操作过于频繁,请1小时后再试',
en: 'please wait a moment try again in an hour',
......
......@@ -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,大小≦40MB</div>
<div className={pageStyle.uploaddesc}>MOV/MP4格式,大小≦**MB</div>
</div>
<div className={pageStyle.right}>
......
......@@ -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>
);
......
......@@ -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',
......
......@@ -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);
......
......@@ -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);
}
}
},
});
}
......@@ -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: 100000,
code: 100001,
errordata: err,
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