-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/daily-channel' into develop
- Loading branch information
Showing
12 changed files
with
821 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export const FETCH_REQUEST = 'DAILY/FETCH_REQUEST'; | ||
export const FETCH_SUCCESS = 'DAILY/FETCH_SUCCESS'; | ||
export const FETCH_FAILURE = 'DAILY/FETCH_FAILURE'; | ||
export const LIKE_REQUEST = 'DAILY/LIKE_REQUEST'; | ||
export const LIKE_SUCCESS = 'DAILY/LIKE_SUCCESS'; | ||
export const LIKE_FAILURE = 'DAILY/LIKE_FAILURE'; | ||
export const DISLIKE_REQUEST = 'DAILY/DISLIKE_REQUEST'; | ||
export const DISLIKE_SUCCESS = 'DAILY/DISLIKE_SUCCESS'; | ||
export const DISLIKE_FAILURE = 'DAILY/DISLIKE_FAILURE'; | ||
export const BAN_REQUEST = 'DAILY/BAN_REQUEST'; | ||
export const BAN_SUCCESS = 'DAILY/BAN_SUCCESS'; | ||
export const BAN_FAILURE = 'DAILY/BAN_FAILURE'; | ||
export const JUMP = 'DAILY/JUMP'; | ||
export const NEXT = 'DAILY/NEXT'; | ||
export const PLAY = 'DAILY/PLAY'; | ||
export const PAUSE = 'DAILY/PAUSE'; | ||
export const REFUSE = 'DAILY/REFUSE'; |
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,127 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { bindActionCreators } from 'redux'; | ||
import { connect } from 'react-redux'; | ||
import { Player } from 'components'; | ||
import { fetch, next, like, dislike, ban, play, pause, jump } from 'reducers/daily'; | ||
import { shortcut } from 'utils'; | ||
import styles from './Daily.scss'; | ||
|
||
@connect( | ||
state => ({ | ||
currentUser: state.auth.user, | ||
song: state.daily.song, | ||
playing: state.daily.playing, | ||
playList: state.daily.playList, | ||
}), | ||
dispatch => ({ | ||
...bindActionCreators({ fetch, next, play, pause, ban, like, dislike, jump }, dispatch) | ||
}) | ||
) | ||
export default class Favorite extends Component { | ||
static propTypes = { | ||
currentUser: PropTypes.object.isRequired, | ||
song: PropTypes.object.isRequired, | ||
playList: PropTypes.array.isRequired, | ||
playing: PropTypes.bool.isRequired, | ||
fetch: PropTypes.func.isRequired, | ||
next: PropTypes.func.isRequired, | ||
play: PropTypes.func.isRequired, | ||
pause: PropTypes.func.isRequired, | ||
like: PropTypes.func.isRequired, | ||
dislike: PropTypes.func.isRequired, | ||
ban: PropTypes.func.isRequired, | ||
jump: PropTypes.func.isRequired, | ||
} | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
const shortcutListener = shortcut.listen( | ||
0, this.onTaste, this.onControl, this.onBan, this.onNext | ||
); | ||
|
||
this.state = { shortcutListener }; | ||
} | ||
|
||
componentDidMount() { | ||
this.props.fetch(); | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if (this.props.currentUser.id === 0 && nextProps.currentUser.id !== 0) { | ||
this.props.fetch(); | ||
} | ||
} | ||
|
||
componentWillUnmount() { | ||
shortcut.stop(this.state.shortcutListener); | ||
} | ||
|
||
onNext = () => { | ||
this.props.next(this.props.song.id); | ||
} | ||
|
||
onControl = () => { | ||
if (this.props.playing) { | ||
this.props.pause(); | ||
} else { | ||
this.props.play(); | ||
} | ||
} | ||
|
||
onTaste = (action) => { | ||
if (action === 'dislike') { | ||
this.props.dislike(this.props.song.id); | ||
} else if (action === 'like') { | ||
this.props.like(this.props.song.id); | ||
} else if (this.props.song.favorite) { | ||
this.props.dislike(this.props.song.id); | ||
} else { | ||
this.props.like(this.props.song.id); | ||
} | ||
} | ||
|
||
onBan = () => { | ||
this.props.ban(this.props.song.id); | ||
} | ||
|
||
onJump = (song) => () => { | ||
this.props.jump(song); | ||
} | ||
|
||
renderContent = (props) => { | ||
const { playing, currentUser, song, playList } = props; | ||
const available = currentUser.id !== 0 && song.id !== 0; | ||
|
||
if (available) { | ||
return ( | ||
<div className={styles.content} > | ||
<div className="player"> | ||
<Player | ||
song={song} | ||
listTitle="每日歌单" | ||
playList={playList} | ||
playing={playing} | ||
onControl={this.onControl} | ||
onTaste={this.onTaste} | ||
onBan={this.onBan} | ||
onNext={this.onNext} | ||
onEnd={this.onNext} | ||
onJump={this.onJump} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className={styles.mask} > | ||
<i className="material-icons" > announcement </i> | ||
Oops, 是不是忘记登录了? | ||
</div> | ||
); | ||
} | ||
|
||
render() { | ||
return this.renderContent(this.props); | ||
} | ||
} |
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,21 @@ | ||
@import '~sass-flex-mixin/flex'; | ||
|
||
.content { | ||
@extend %flexbox; | ||
@include justify-content(center); | ||
} | ||
|
||
.mask { | ||
height: 20rem; | ||
text-align: center; | ||
line-height: 20rem; | ||
font-size: 0.8rem; | ||
font-weight: 400; | ||
color: #9b9b9b; | ||
text-decoration: underline; | ||
|
||
> i { | ||
font-size: 2rem; | ||
margin-right: 0.5rem; | ||
} | ||
} |
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
Oops, something went wrong.