From 3aa38f1f39ef536e22f2e75f8cf41a97013b1b91 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Mon, 12 Aug 2019 17:35:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/usersInfo/video/VideoReducer.js | 22 +++++++++++------- .../user/usersInfo/video/VideoUpload.js | 4 ++-- .../user/usersInfo/video/VideoUploadList.js | 23 ++++++++++--------- .../modules/user/usersInfo/video/VideoUtil.js | 13 +++++++++++ 4 files changed, 41 insertions(+), 21 deletions(-) create mode 100644 public/react/src/modules/user/usersInfo/video/VideoUtil.js 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) {