|
|
|
@ -65,8 +65,9 @@ function InfoVideo(props) {
|
|
|
|
|
const videoEl = useRef(null);
|
|
|
|
|
|
|
|
|
|
const { showNotification, history } = props;
|
|
|
|
|
const username = props.match.params.username
|
|
|
|
|
|
|
|
|
|
const username = props.match.params.username;
|
|
|
|
|
const { user } = props;
|
|
|
|
|
console.log(user);
|
|
|
|
|
function toUpload() {
|
|
|
|
|
if (props.current_user.admin || (props.current_user.is_teacher && props.checkIfProfessionalCertification())) {
|
|
|
|
|
history.push(`/users/${username}/videos/upload`)
|
|
|
|
@ -87,16 +88,15 @@ function InfoVideo(props) {
|
|
|
|
|
sort_direction: sorts[1],
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}).then((response) => {
|
|
|
|
|
setLoading(false)
|
|
|
|
|
if (response.data.videos) {
|
|
|
|
|
setvideos(response.data.videos)
|
|
|
|
|
setCount(response.data.count)
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
setLoading(false)
|
|
|
|
|
})
|
|
|
|
|
.then((response) => {
|
|
|
|
|
setLoading(false)
|
|
|
|
|
if (response.data.videos) {
|
|
|
|
|
setvideos(response.data.videos)
|
|
|
|
|
setCount(response.data.count)
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
setLoading(false)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
function fetchReviewvideos() {
|
|
|
|
|
const fetchUrl = `/users/${username}/videos/review.json`
|
|
|
|
@ -184,9 +184,8 @@ function InfoVideo(props) {
|
|
|
|
|
videoId = {
|
|
|
|
|
videoId: item.id,
|
|
|
|
|
title: item.title,
|
|
|
|
|
file_url: item.file_url,
|
|
|
|
|
file_url: item.play_url || item.file_url,
|
|
|
|
|
cover_url: item.cover_url
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
videoModalObj.setVisible(true)
|
|
|
|
|
}
|
|
|
|
@ -218,6 +217,36 @@ function InfoVideo(props) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteVideo(item){
|
|
|
|
|
props.confirm({
|
|
|
|
|
content: '该视频将被删除,不可恢复',
|
|
|
|
|
subContent: '是否确认删除?',
|
|
|
|
|
|
|
|
|
|
onOk: () => {
|
|
|
|
|
const url = `/users/${user && user.login}/videos/${item.id}.json`;
|
|
|
|
|
axios.delete(url).then(result => {
|
|
|
|
|
if (result) {
|
|
|
|
|
props.showNotification(`视频删除成功!`);
|
|
|
|
|
if (pageObj.current === 1) {
|
|
|
|
|
if (categoryObj.category === 'all') {
|
|
|
|
|
fetchvideos()
|
|
|
|
|
} else {
|
|
|
|
|
fetchReviewvideos()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
pageObj.onChange(1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
console.log(error);
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
onCancel() {
|
|
|
|
|
console.log('Cancel');
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function getCopyText(file_url, cover_url) {
|
|
|
|
|
return `<video src="${file_url}" controls="true" controlslist="nodownload" width="${DEFAULT_VIDEO_WIDTH_IN_MD}" height="${DEFAULT_VIDEO_HEIGHT_IN_MD}" poster="${cover_url}">您的浏览器不支持 video 标签。</video>`
|
|
|
|
|
}
|
|
|
|
@ -397,7 +426,7 @@ function InfoVideo(props) {
|
|
|
|
|
onEditVideo={onEditVideo}
|
|
|
|
|
onMaskClick={onMaskClick}
|
|
|
|
|
getCopyText={getCopyText}
|
|
|
|
|
|
|
|
|
|
deleteVideo={user && ((user.login === item.user_login) || user.admin) ? deleteVideo : undefined}
|
|
|
|
|
>
|
|
|
|
|
</VideoInReviewItem>)
|
|
|
|
|
})
|
|
|
|
@ -416,6 +445,7 @@ function InfoVideo(props) {
|
|
|
|
|
{...item}
|
|
|
|
|
key={item.id}
|
|
|
|
|
isReview={true}
|
|
|
|
|
deleteVideo={user && ((user.login === item.user_login) || user.admin) ? deleteVideo : undefined}
|
|
|
|
|
>
|
|
|
|
|
</VideoInReviewItem>)
|
|
|
|
|
})
|
|
|
|
|