|
|
|
@ -15,12 +15,33 @@ let uploader
|
|
|
|
|
const files = []
|
|
|
|
|
const MAX_FILE_COUNT = 3
|
|
|
|
|
const MAX_FILE_SIZE = 200
|
|
|
|
|
let noUploads = true
|
|
|
|
|
function VideoUploadList (props) {
|
|
|
|
|
|
|
|
|
|
const [videoes, setVideoes] = useState([]);
|
|
|
|
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
|
|
|
const theme = useContext(ThemeContext)
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
window.addEventListener("beforeunload", beforeunload);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
window.removeEventListener("beforeunload", beforeunload);
|
|
|
|
|
}
|
|
|
|
|
}, [])
|
|
|
|
|
// TODO 闭包!
|
|
|
|
|
noUploads = (!state.videoes || state.videoes.length == 0);
|
|
|
|
|
function beforeunload(e) {
|
|
|
|
|
if (noUploads) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
var confirmationMessage = "确认要离开当前页面,当前数据不可恢复";
|
|
|
|
|
|
|
|
|
|
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
|
|
|
|
|
return confirmationMessage; //Webkit, Safari, Chrome etc.
|
|
|
|
|
}
|
|
|
|
|
const _beforeunload = beforeunload // .bind(this, noUploads, state)
|
|
|
|
|
|
|
|
|
|
const username = props.match.params.username
|
|
|
|
|
const { showNotification, history } = props;
|
|
|
|
|
const uploaderOptions = {
|
|
|
|
@ -188,7 +209,6 @@ function VideoUploadList (props) {
|
|
|
|
|
dispatch({type: 'updateTitle', title, index})
|
|
|
|
|
}
|
|
|
|
|
// login
|
|
|
|
|
const noUploads = (!state.videoes || state.videoes.length == 0);
|
|
|
|
|
const protocolLine = <div>上传视频,即表示您已同意<span style={{color: theme.foreground_select}}>上传内容协议</span>,不得上传未经他人授权的作品</div>
|
|
|
|
|
return (
|
|
|
|
|
<div className="educontent videoUploadList" style={{ marginBottom: '200px' }}>
|
|
|
|
@ -204,6 +224,10 @@ function VideoUploadList (props) {
|
|
|
|
|
.videoUploadList .cBreadcrumb {
|
|
|
|
|
margin-top: 16px;
|
|
|
|
|
}
|
|
|
|
|
.videoUploadList .uploadTip {
|
|
|
|
|
line-height: 18px;
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
}
|
|
|
|
|
.videoUploadList .title {
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
}
|
|
|
|
@ -231,6 +255,7 @@ function VideoUploadList (props) {
|
|
|
|
|
.videoUploadList .publishRow .publishBtn {
|
|
|
|
|
padding: 6px 24px;
|
|
|
|
|
height: auto;
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
}
|
|
|
|
|
.videoUploadList .addVideoBtn {
|
|
|
|
|
position: absolute;
|
|
|
|
@ -307,12 +332,12 @@ function VideoUploadList (props) {
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
{state.videoes && state.videoes.length === MAX_FILE_COUNT &&
|
|
|
|
|
<div className="tip">
|
|
|
|
|
<div className="uploadTip">
|
|
|
|
|
<i className="iconfont icon-tishi" style={{color: '#FF6F6F', verticalAlign: 'text-bottom'}}></i>
|
|
|
|
|
<span>单次最多支持3个视频文件上传</span>
|
|
|
|
|
</div>}
|
|
|
|
|
|
|
|
|
|
{!noUploads && <ActionBtn className="publishBtn" onClick={() => document.getElementById('fileUpload').click()}
|
|
|
|
|
{(!noUploads && state.videoes.length < MAX_FILE_COUNT) && <ActionBtn className="publishBtn" onClick={() => document.getElementById('fileUpload').click()}
|
|
|
|
|
>继续添加</ActionBtn>}
|
|
|
|
|
|
|
|
|
|
<div className={`description ${noUploads ? 'noUploads' : ''}`}>
|
|
|
|
|