-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
270 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import { classNames, PropTypes, SearchField, ImageList } from '../../third_party'; | ||
import EditWindow from './window/EditWindow.jsx'; | ||
import ModelLoader from '../../loader/ModelLoader'; | ||
import AddObjectCommand from '../../command/AddObjectCommand'; | ||
import UploadUtils from '../../utils/UploadUtils'; | ||
|
||
/** | ||
* 视频面板 | ||
* @author tengge / https://github.com/tengge1 | ||
*/ | ||
class VideoPanel extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
data: [], | ||
categoryData: [], | ||
name: '', | ||
categories: [], | ||
}; | ||
|
||
this.handleClick = this.handleClick.bind(this); | ||
|
||
this.handleEdit = this.handleEdit.bind(this); | ||
this.handleDelete = this.handleDelete.bind(this); | ||
|
||
this.update = this.update.bind(this); | ||
} | ||
|
||
render() { | ||
const { className, style } = this.props; | ||
const { data, categoryData, name, categories } = this.state; | ||
|
||
let list = data; | ||
|
||
if (name.trim() !== '') { | ||
list = list.filter(n => { | ||
return n.Name.toLowerCase().indexOf(name.toLowerCase()) > -1 || | ||
n.FirstPinYin.toLowerCase().indexOf(name.toLowerCase()) > -1 || | ||
n.TotalPinYin.toLowerCase().indexOf(name.toLowerCase()) > -1; | ||
}); | ||
} | ||
|
||
if (categories.length > 0) { | ||
list = list.filter(n => { | ||
return categories.indexOf(n.CategoryID) > -1; | ||
}); | ||
} | ||
|
||
const imageListData = list.map(n => { | ||
return Object.assign({}, n, { | ||
id: n.ID, | ||
src: n.Thumbnail ? `${app.options.server}${n.Thumbnail}` : null, | ||
title: n.Name, | ||
icon: 'scenes', | ||
}); | ||
}); | ||
|
||
return <div className={classNames('VideoPanel', className)} style={style}> | ||
<SearchField | ||
data={categoryData} | ||
placeholder={_t('Search Content')} | ||
addHidden={true} | ||
onInput={this.handleSearch.bind(this)}></SearchField> | ||
<ImageList | ||
data={imageListData} | ||
onClick={this.handleClick} | ||
onEdit={this.handleEdit} | ||
onDelete={this.handleDelete}></ImageList> | ||
</div>; | ||
} | ||
|
||
componentDidUpdate(prevProps, prevState) { | ||
if (this.init === undefined && this.props.show === true) { | ||
this.init = true; | ||
this.update(); | ||
} | ||
} | ||
|
||
update() { | ||
fetch(`${app.options.server}/api/Category/List?type=Video`).then(response => { | ||
response.json().then(obj => { | ||
this.setState({ | ||
categoryData: obj.Data, | ||
}); | ||
}); | ||
}); | ||
fetch(`${app.options.server}/api/Video/List`).then(response => { | ||
response.json().then(obj => { | ||
this.setState({ | ||
data: obj.Data, | ||
}); | ||
}); | ||
}); | ||
} | ||
|
||
handleSearch(name, categories, event) { | ||
this.setState({ | ||
name, | ||
categories, | ||
}); | ||
} | ||
|
||
handleClick(data) { | ||
app.video(data.Url); | ||
} | ||
|
||
// ------------------------------- 编辑 --------------------------------------- | ||
|
||
handleEdit(data) { | ||
var win = app.createElement(EditWindow, { | ||
type: 'Video', | ||
typeName: _t('Video'), | ||
data, | ||
saveUrl: `${app.options.server}/api/Video/Edit`, | ||
callback: this.update, | ||
}); | ||
|
||
app.addElement(win); | ||
} | ||
|
||
// ------------------------------ 删除 ---------------------------------------- | ||
|
||
handleDelete(data) { | ||
app.confirm({ | ||
title: _t('Confirm'), | ||
content: `${_t('Delete')} ${data.title}?`, | ||
onOK: () => { | ||
fetch(`${app.options.server}/api/Video/Delete?ID=${data.id}`, { | ||
method: 'POST', | ||
}).then(response => { | ||
response.json().then(obj => { | ||
if (obj.Code === 200) { | ||
this.update(); | ||
} | ||
app.toast(obj.Msg); | ||
}); | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
VideoPanel.propTypes = { | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
show: PropTypes.bool, | ||
}; | ||
|
||
VideoPanel.defaultProps = { | ||
className: null, | ||
style: null, | ||
show: false, | ||
}; | ||
|
||
export default VideoPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import './css/Video.css'; | ||
import classNames from 'classnames/bind'; | ||
import PropTypes from 'prop-types'; | ||
|
||
/** | ||
* 视频查看器 | ||
*/ | ||
class Video extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.handleClick = this.handleClick.bind(this, props.onClick); | ||
this.handleClickImage = this.handleClickVideo.bind(this); | ||
} | ||
|
||
render() { | ||
const { className, style, url } = this.props; | ||
|
||
return <div className={'VideoMark'} onClick={this.handleClick}> | ||
<video src={url} autoPlay={'autoplay'} controls={'controls'} onClick={this.handleClickVideo} /> | ||
</div>; | ||
} | ||
|
||
handleClick(onClick, event) { | ||
onClick && onClick(event); | ||
} | ||
|
||
handleClickVideo(event) { | ||
event.stopPropagation(); | ||
} | ||
} | ||
|
||
Video.propTypes = { | ||
className: PropTypes.string, | ||
style: PropTypes.object, | ||
url: PropTypes.string, | ||
onClick: PropTypes.func, | ||
}; | ||
|
||
Video.defaultProps = { | ||
className: null, | ||
style: null, | ||
url: null, | ||
onClick: null, | ||
}; | ||
|
||
export default Video; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.VideoMark { | ||
position: fixed; | ||
left: 0; | ||
top: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(0, 0, 0, 0.8); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
z-index: 1300; | ||
} | ||
|
||
.VideoMark>video { | ||
max-width: 80%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters