From f5a50a149dae3e852387b30c5a2a35f1d90ce4c1 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 16 Aug 2019 13:36:07 +0800 Subject: [PATCH] closure --- .../common/components/media/AliyunUploader.js | 2 +- .../user/usersInfo/video/InfosVideo.js | 1 + .../usersInfo/video/VideoPublishSuccess.js | 14 +++++--- .../user/usersInfo/video/VideoUploadList.js | 31 ++++++++++++++++-- .../user/usersInfo/video/images/ok_border.png | Bin 0 -> 491 bytes 5 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 public/react/src/modules/user/usersInfo/video/images/ok_border.png diff --git a/public/react/src/common/components/media/AliyunUploader.js b/public/react/src/common/components/media/AliyunUploader.js index 7a77c9feb..6d93b3076 100644 --- a/public/react/src/common/components/media/AliyunUploader.js +++ b/public/react/src/common/components/media/AliyunUploader.js @@ -21,7 +21,7 @@ function createUploader () { retryCount: $('#retryCount').val() || 3, retryDuration: $('#retryDuration').val() || 2, region: $('#region').val() || 'ap-southeast-1', - userId: $('#userId').val() || 1202060945918292, // 1303984639806000, + userId: $('#userId').val() || 1829848226361863, // 1202060945918292, // 1303984639806000, // 添加文件成功 addFileSuccess: function (uploadInfo) { console.log('addFileSuccess') diff --git a/public/react/src/modules/user/usersInfo/video/InfosVideo.js b/public/react/src/modules/user/usersInfo/video/InfosVideo.js index 35035fef7..e1d88724f 100644 --- a/public/react/src/modules/user/usersInfo/video/InfosVideo.js +++ b/public/react/src/modules/user/usersInfo/video/InfosVideo.js @@ -101,6 +101,7 @@ function InfoVideo (props) { .then((response) => { if (response.data.videos) { setReviewVideoes(response.data.videos) + setCount(response.data.count) } }).catch(() => { diff --git a/public/react/src/modules/user/usersInfo/video/VideoPublishSuccess.js b/public/react/src/modules/user/usersInfo/video/VideoPublishSuccess.js index d0cd04b06..f0b8c85e4 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoPublishSuccess.js +++ b/public/react/src/modules/user/usersInfo/video/VideoPublishSuccess.js @@ -2,6 +2,7 @@ import React, { useState, useEffect, useContext, memo } from 'react'; import { Progress, Input } from 'antd' import { getUrl2, isDev, CBreadcrumb, ActionBtn, ThemeContext } from 'educoder' import axios from 'axios' +import okIcon from './images/ok_border.png' function VideoUpload (props) { const theme = useContext(ThemeContext); @@ -18,7 +19,7 @@ function VideoUpload (props) { return (
{` .videoPublishSuccess .section { background: #fff; - padding: 16px 20px; - padding-top: 0px; + padding: 72px 20px; position: relative; text-align: center; color: ${theme.foreground_tip}; } + .videoPublishSuccess img.ok { + width: 64px; + margin: 16px; + margin-top: 0px; + } .videoPublishSuccess .tip { margin-top: 10px; margin-bottom: 12px; @@ -50,7 +55,8 @@ function VideoUpload (props) {
- + + {/* */}
恭喜!
提交成功
diff --git a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js index e158f80b0..06a4029da 100644 --- a/public/react/src/modules/user/usersInfo/video/VideoUploadList.js +++ b/public/react/src/modules/user/usersInfo/video/VideoUploadList.js @@ -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 =
上传视频,即表示您已同意上传内容协议,不得上传未经他人授权的作品
return (
@@ -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) { })}
{state.videoes && state.videoes.length === MAX_FILE_COUNT && -
+
单次最多支持3个视频文件上传
} - {!noUploads && document.getElementById('fileUpload').click()} + {(!noUploads && state.videoes.length < MAX_FILE_COUNT) && document.getElementById('fileUpload').click()} >继续添加}
diff --git a/public/react/src/modules/user/usersInfo/video/images/ok_border.png b/public/react/src/modules/user/usersInfo/video/images/ok_border.png new file mode 100644 index 0000000000000000000000000000000000000000..bd0c7dce04fb793d22cec05205ddbffa52d48050 GIT binary patch literal 491 zcmVW(^85}@J_0_kF7wl2^$@tjO|GAgOIY)S_2rs00uCC0&x7s z07VsEAV3{25dcuc3up@f>hUgD1Cjt@kOY7|7zH+ZKoU4NYCuL{IUpmj7?2ZK49E#E zfb~zeK!5?%;nKQ?MYA2c-F}6$SEuyJ-;T1@eG2Ki?D>fjr5L`z=;CV ziR2{#3E(6F@l5oBfCv~AKClVp@nln)0SsV(e+7V}FgT2Z<3Ko&gd