diff --git a/public/react/src/modules/user/usersInfo/video/VideoReducer.js b/public/react/src/modules/user/usersInfo/video/VideoReducer.js index bef858c81..fda577fa0 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoReducer.js +++ b/public/react/src/modules/user/usersInfo/video/VideoReducer.js @@ -21,18 +21,24 @@ export function reducer(state, action) { case 'updateProgress': let _index = -1; state.videoes.some((item, index) => { - // addFileSuccess的时候没有fileHash - // if (uploadInfo.fileHash == item.fileHash) { - if (action.uploadInfo.fileHash == item.fileHash || action.uploadInfo.file.name == item.name) { + // 同文件不同名字 fileHash也是一样的 + if (item.loaded != 100 && (action.uploadInfo.fileHash == item.fileHash && action.uploadInfo.file.name == item.name)) { _index = index return true; } }) - return {videoes: update(state.videoes, {[_index]: { - loaded: {$set: action.progressPercent}, - videoId: {$set: action.uploadInfo.videoId}, - fileHash: {$set: action.uploadInfo.fileHash} - }})}; + let newVideoes = state.videoes + // 删除先执行 + if (_index != -1) { + newVideoes = update(state.videoes, {[_index]: { + loaded: {$set: action.progressPercent}, + + videoId: {$set: action.uploadInfo.videoId}, + // addFileSuccess的时候没有fileHash + fileHash: {$set: action.uploadInfo.fileHash} + }}) + } + return {videoes: newVideoes}; default: throw new Error(); } diff --git a/public/react/src/modules/user/usersInfo/video/VideoUpload.js b/public/react/src/modules/user/usersInfo/video/VideoUpload.js index 397baa9a5..dc936c48f 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoUpload.js +++ b/public/react/src/modules/user/usersInfo/video/VideoUpload.js @@ -4,7 +4,7 @@ import { getUrl2, isDev, CBreadcrumb, ActionBtn } from 'educoder' import axios from 'axios' -const MAX_LENGTH = 60 +const MAX_LENGTH = 30 /** name: file.name, @@ -30,7 +30,7 @@ function VideoUpload (props) {
{index+1}. {name}
cancelUpload(index, loaded == '100' )}>{loaded == '100' ? "删除" : "取消上传"}
diff --git a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js index 28a562cde..2cc5f3340 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js +++ b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js @@ -8,7 +8,7 @@ import { Button } from 'antd' import { getUploader } from './AliyunUploaderManager' import { reducer, initialState } from './VideoReducer' - +import { deleteVideoInCloud } from './VideoUtil' let uploader const files = [] function VideoUploadList (props) { @@ -16,7 +16,7 @@ function VideoUploadList (props) { const [videoes, setVideoes] = useState([]); const [state, dispatch] = useReducer(reducer, initialState); const username = props.match.params.username - + const { showNotification } = props; const uploaderOptions = { } @@ -121,22 +121,23 @@ function VideoUploadList (props) { } // uploader.deleteFile(index); function cancelUpload(index, isSuccess) { - // 确定取消? - - // const file = files[index] + // TODO 确定取消? + uploader.deleteFile(index) if (isSuccess) { - uploader.deleteFile(index) - } else { - uploader.cancelFile(index) - } - // files.splice(index, 1) + deleteVideoInCloud(username, state.videoes[index].videoId) + } + // else { + // uploader.cancelFile(index) + // } + const _input = document.getElementById('fileUpload') + _input.value = '' dispatch({type: 'removeVideo', index}) // setVideoes([...videoes.splice(index, 1)]) } function onPublish() { if (state.videoes.length == 0) { - this.props.showNotification('请先上传视频') + showNotification('请先上传视频') return; } const publishUrl = `/users/${username}/videos/batch_publish.json` diff --git a/public/react/src/modules/user/usersInfo/video/VideoUtil.js b/public/react/src/modules/user/usersInfo/video/VideoUtil.js new file mode 100644 index 000000000..327a691ee --- /dev/null +++ b/public/react/src/modules/user/usersInfo/video/VideoUtil.js @@ -0,0 +1,13 @@ +import axios from 'axios' + +export function deleteVideoInCloud(login, video_id) { + const url = `/users/${login}/videos/cancel.json` + axios.post(url, { + video_id + }).then((response) => { + + + }).catch((error) => { + console.log(error) + }) +} \ No newline at end of file