dev_hjm^2
hjm 6 years ago
parent 58e54dd802
commit dddb9a0aea

@ -63,4 +63,14 @@ html, body {
border-left: 1px solid rgb(221, 221, 221); border-left: 1px solid rgb(221, 221, 221);
/* 某些情况下被cm盖住了 */ /* 某些情况下被cm盖住了 */
z-index: 99; z-index: 99;
}
/* antd扩展 */
.formItemInline.ant-form-item {
display: flex;
}
.formItemInline .ant-form-item-control-wrapper {
flex: 1;
} }

@ -5,7 +5,8 @@ export const themes = {
foreground: '#000000', foreground: '#000000',
background: '#eeeeee', background: '#eeeeee',
foreground_select: '#4CACFF', foreground_select: '#4CACFF',
foreground_tip: '#333' foreground_orange1: '#FF6800',
foreground_tip: '#333',
}, },
dark: { dark: {

@ -0,0 +1,46 @@
import React, { useState, useEffect, useContext, useRef, memo } from 'react';
import {Link} from 'react-router-dom';
import { getUrl2, isDev, ThemeContext } from 'educoder'
import { Modal } from 'antd'
function HeadlessModal (props) {
// const [ visible, setVisible ] = useState(false)
const theme = useContext(ThemeContext);
const { category, visible, setVisible, className, width } = props;
useEffect(() => {
}, [])
return (
<Modal
visible={visible}
className={`headless ${className}`}
title={null}
footer={null}
width={width}
>
<style>{`
.headless .ant-modal-close {
display:none;
}
.headless .ant-modal-body {
padding: 0px;
}
.headless .closeBtn {
position: absolute;
top: -15px;
right: -9px;
color: ${theme.foreground_select}
}
`}</style>
<i className="iconfont icon-htmal5icon19 closeBtn" onClick={ () => setVisible(false) }></i>
{props.children}
</Modal>
)
}
export default HeadlessModal

@ -0,0 +1,32 @@
import React, { useState, useEffect, useContext, useRef, memo } from 'react';
import {Link} from 'react-router-dom';
import { getUrl2, isDev, ThemeContext } from 'educoder'
import axios from 'axios'
function InfoTab (props) {
const theme = useContext(ThemeContext);
const { category, changeCategory, categories } = props;
const username = props.match.params.username
useEffect(() => {
}, [])
return (
<div className="white-panel edu-back-white pt25 pb25 clearfix ">
{categories && categories.map(item => {
return (
<li key={item.key} className={category == item.key ? "active" : ''}><a href="javascript:void(0)" onClick={()=>changeCategory(item.key)}>{item.name}</a></li>
)
})}
{/* <li className={category ? "" : "active"}><a href="javascript:void(0)" onClick={()=>this.changeCategory()}></a></li>
<li className={category=="manage" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeCategory("manage")}>{is_current ? "我":"TA"}管理的</a></li>
<li className={category=="study" ? "active" : ""}><a href="javascript:void(0)" onClick={()=>this.changeCategory("study")}>{is_current ? "我":"TA"}学习的</a></li> */}
</div>
)
}
export default InfoTab

@ -6,10 +6,12 @@ import axios from 'axios'
function EditVideoModal (props) { function EditVideoModal (props) {
const modalEl = useRef(null); const modalEl = useRef(null);
const theme = useContext(ThemeContext); const theme = useContext(ThemeContext);
const { history, id, cover_url, title, created_at, isReview, onEditVideo, visible, setVisible, const { history, videoId, cover_url, title, created_at, isReview, onEditVideo, visible, setVisible,
form } = props; form, editSuccess } = props;
const getFieldDecorator = form.getFieldDecorator const getFieldDecorator = form.getFieldDecorator
const username = props.match.params.username const username = props.match.params.username
const _title = form.getFieldsValue().title;
function toList() { function toList() {
history.push(`/users/${username}/videoes`) history.push(`/users/${username}/videoes`)
} }
@ -20,8 +22,17 @@ function EditVideoModal (props) {
form.validateFieldsAndScroll((err, values) => { form.validateFieldsAndScroll((err, values) => {
if (!err) { if (!err) {
const url = `/users/${username}/videos/${videoId}.json`
axios.put(url, {
title: _title
}).then((response) => {
if (response.data) {
onCancel()
editSuccess()
}
}).catch((e) => {
})
} else { } else {
// $("html").animate({ scrollTop: $('html').scrollTop() - 100 }) // $("html").animate({ scrollTop: $('html').scrollTop() - 100 })
} }
@ -36,7 +47,11 @@ function EditVideoModal (props) {
useEffect(() => { useEffect(() => {
modalEl.current.setVisible(visible) modalEl.current.setVisible(visible)
}, [visible]) }, [visible])
const _title = form.getFieldsValue().title; useEffect(() => {
visible && form.setFieldsValue({
title,
})
}, [visible])
return ( return (
<ModalWrapper <ModalWrapper
ref={modalEl} ref={modalEl}
@ -49,7 +64,7 @@ function EditVideoModal (props) {
> >
<Form.Item <Form.Item
label="视频标题" label="视频标题"
className="title " className="title formItemInline"
> >
{getFieldDecorator('title', { {getFieldDecorator('title', {

@ -1,11 +1,13 @@
import React, { useState, useEffect, useContext, useRef, memo } from 'react'; import React, { useState, useEffect, useContext, useRef, memo } from 'react';
import {Link} from 'react-router-dom'; import {Link} from 'react-router-dom';
import { Pagination } from 'antd'
import { getUrl2, isDev, ThemeContext } from 'educoder' import { getUrl2, isDev, ThemeContext } from 'educoder'
import axios from 'axios' import axios from 'axios'
import VideoInReviewItem from './VideoInReviewItem' import VideoInReviewItem from './VideoInReviewItem'
import EditVideoModal from './EditVideoModal' import EditVideoModal from './EditVideoModal'
import './InfosVideo.css' import './InfosVideo.css'
import InfoTab from '../common/InfoTab'
import HeadlessModal from '../common/HeadlessModal'
function useModal(initValue) { function useModal(initValue) {
const [visible, setVisible] = useState(initValue) const [visible, setVisible] = useState(initValue)
@ -15,30 +17,59 @@ function useModal(initValue) {
setVisible setVisible
} }
} }
function useCategory(initValue) {
const [category, setCategory] = useState(initValue)
function changeCategory(key) {
setCategory(key)
}
return {
category,
changeCategory
}
}
function usePagination() {
const [page, setPage] = useState(1)
function onPageChange(page) {
setPage(page)
}
return {
current: page,
onChange: onPageChange
}
}
const PAGE_SIZE = 3
let videoId = {};
const PAGE_SIZE = 12
function InfoVideo (props) { function InfoVideo (props) {
const [videoes, setVideoes] = useState([]) const [videoes, setVideoes] = useState([])
const [reviewVideoes, setReviewVideoes] = useState([]) const [reviewVideoes, setReviewVideoes] = useState([])
const [count, setCount] = useState(0)
const editModalObj = useModal(false) const editModalObj = useModal(false)
const videoModalObj = useModal(false)
const categoryObj = useCategory('all')
const pageObj = usePagination()
const theme = useContext(ThemeContext); const theme = useContext(ThemeContext);
const editModalEl = useRef(null); const editModalEl = useRef(null);
const videoEl = useRef(null);
const username = props.match.params.username const username = props.match.params.username
let cVideo = {};
function fetchVideoes() { function fetchVideoes() {
const fetchUrl = `/users/${username}/videos.json` const fetchUrl = `/users/${username}/videos.json`
axios.get(fetchUrl, { axios.get(fetchUrl, {
params: { params: {
per_page: PAGE_SIZE page: pageObj.current,
per_page: PAGE_SIZE,
// sort_by
// sort_direction
} }
}) })
.then((response) => { .then((response) => {
if (response.data.videos) { if (response.data.videos) {
setVideoes(response.data.videos) setVideoes(response.data.videos)
setCount(response.data.count)
} }
}).catch(() => { }).catch(() => {
@ -62,20 +93,68 @@ function InfoVideo (props) {
useEffect(() => { useEffect(() => {
fetchVideoes() fetchVideoes()
fetchReviewVideoes() }, [pageObj.current])
}, [])
function onEditVideo(video) { useEffect(() => {
cVideo = video if (categoryObj.category == 'all') {
fetchVideoes()
} else {
fetchReviewVideoes()
}
}, [categoryObj.category])
useEffect(() => {
if (videoModalObj.visible == false) {
// 关闭视频
videoEl.current && videoEl.current.pause()
} else {
}
}, [videoModalObj.visible])
function editSuccess() {
fetchVideoes()
}
function onEditVideo(item) {
videoId = {
videoId: item.id,
title: item.title
}
editModalObj.setVisible(true) editModalObj.setVisible(true)
// editModalEl.current.toList(true, video); // editModalEl.current.toList(true, video);
// this.refs['editVideoModal'].setVisible(true, video); // this.refs['editVideoModal'].setVisible(true, video);
} }
function onMaskClick(item) {
videoId = {
videoId: item.id,
title: item.title,
file_url: item.file_url
}
videoModalObj.setVisible(true)
}
return ( return (
<div className="educontent infoVideo"> <div className="educontent infoVideo">
<EditVideoModal ref={editModalEl} {...props} {...cVideo} {...editModalObj}></EditVideoModal> <EditVideoModal {...props} {...editModalObj}
editSuccess={editSuccess}
{...videoId}
></EditVideoModal>
<HeadlessModal
{...videoModalObj}
className="showVideoModal"
width={800 - 1}
>
<video
ref="videoEl"
src={videoId.file_url} controls="true" controlslist="nodownload">
您的浏览器不支持 video 标签
</video>
</HeadlessModal>
<style>{` <style>{`
.showVideoModal video{
width: 800px;
height: 450px;
}
/* item */ /* item */
.videoPublishSuccess .section { .videoPublishSuccess .section {
@ -96,33 +175,69 @@ function InfoVideo (props) {
} }
`}</style> `}</style>
<InfoTab
{...props}
categories={[{
key: 'all',
name: '全部视频'
}, {
key: 'review',
name: '待审核视频'
}]}
{...categoryObj}
></InfoTab>
<div className="toolbarRow mt20">
<span>
<span style={{color: theme.foreground_orange1}}> {count} </span>
个视频
</span>
<div className="itemWrap">
{reviewVideoes.map((item, index) => { </div>
{categoryObj.category == 'all' ?
<div className="itemWrap">
{videoes.map((item, index) => {
return (<VideoInReviewItem return (<VideoInReviewItem
{...props} {...props}
{...item} {...item}
key={item.id} key={item.id}
isReview={true} onEditVideo={onEditVideo}
onMaskClick={onMaskClick}
> >
</VideoInReviewItem>) </VideoInReviewItem>)
})} })}
</div> </div>
:
gogogo
<div className="itemWrap"> <div className="itemWrap">
{videoes.map((item, index) => { {reviewVideoes.map((item, index) => {
return (<VideoInReviewItem return (<VideoInReviewItem
{...props} {...props}
{...item} {...item}
key={item.id} key={item.id}
onEditVideo={onEditVideo} isReview={true}
> >
</VideoInReviewItem>) </VideoInReviewItem>)
})} })}
</div> </div>
}
{
categoryObj.category == 'all' && count > PAGE_SIZE &&
<div className="mt30 mb50 edu-txt-center">
<Pagination showQuickJumper total={count} pageSize={PAGE_SIZE}
{...pageObj}
/>
</div>
}
<Link to={`/users/${username}/videoes/upload`}>to upload</Link> <Link to={`/users/${username}/videoes/upload`}>to upload</Link>
</div> </div>
) )

@ -16,7 +16,8 @@ updated_at: "2019-08-12 17:17:09"
*/ */
function VideoInReviewItem (props) { function VideoInReviewItem (props) {
const theme = useContext(ThemeContext); const theme = useContext(ThemeContext);
const { history, cover_url, title, created_at, isReview, onEditVideo } = props; const { history, cover_url, title, created_at, isReview
, onEditVideo, onMaskClick } = props;
const username = props.match.params.username const username = props.match.params.username
function toList() { function toList() {
@ -30,7 +31,7 @@ function VideoInReviewItem (props) {
<img className="cover" src={cover_url || "http://video.educoder.net/e7d18970482a46d2a6f0e951b504256c/snapshots/491e113950d74f1dab276097dae287dd-00005.jpg"} <img className="cover" src={cover_url || "http://video.educoder.net/e7d18970482a46d2a6f0e951b504256c/snapshots/491e113950d74f1dab276097dae287dd-00005.jpg"}
></img> ></img>
{!isReview && <div className="mask"> {!isReview && <div className="mask" onClick={() => onMaskClick(props)}>
<img className="play" src={playIcon}></img> <img className="play" src={playIcon}></img>
</div>} </div>}
<div className="square-main"> <div className="square-main">

Loading…
Cancel
Save