- user-center
+
+
+
+
+
+
+
+
+
+ 随机播放全部
+
+
+ {
+ this.state.currentIndex === 0
+ ?
+
+
+
+
+
+ :
+
+
+
+
+
+ }
+
)
}
-}
\ No newline at end of file
+}
+
+User = connect(state => state, {insertSong})(User)
+
+export default User
\ No newline at end of file
diff --git a/src/components/user/user.styl b/src/components/user/user.styl
new file mode 100644
index 0000000..88dfcb5
--- /dev/null
+++ b/src/components/user/user.styl
@@ -0,0 +1,59 @@
+@import "~common/styl/variable"
+
+.user-center
+ position: fixed
+ top: 0
+ bottom: 0
+ z-index: 100
+ width: 100%
+ background: $color-background
+ transform translate3d(100%, 0, 0)
+ transition all 0.3s
+ &.fade
+ transform translate3d(0, 0, 0)
+ .back
+ position absolute
+ top: 0
+ left: 6px
+ z-index: 50
+ .icon-back
+ display: block
+ padding: 10px
+ font-size: $font-size-large-x
+ color: $color-theme
+ .switches-wrapper
+ margin: 10px 0 30px 0
+ .play-btn
+ box-sizing: border-box
+ width: 135px
+ padding: 7px 0
+ margin: 0 auto
+ text-align: center
+ border: 1px solid $color-text-l
+ color: $color-text-l
+ border-radius: 100px
+ font-size: 0
+ .icon-play
+ display: inline-block
+ vertical-align: middle
+ margin-right: 6px
+ font-size: $font-size-medium-x
+ .text
+ display: inline-block
+ vertical-align: middle
+ font-size: $font-size-small
+ .list-wrapper
+ position: absolute
+ top: 110px
+ bottom: 0
+ width: 100%
+ .list-scroll
+ height: 100%
+ overflow: hidden
+ .list-inner
+ padding: 20px 30px
+ .no-result-wrapper
+ position: absolute
+ width: 100%
+ top: 50%
+ transform: translateY(-50%)
\ No newline at end of file
diff --git a/src/store/action-creator.js b/src/store/action-creator.js
index f669ace..ab9b48d 100644
--- a/src/store/action-creator.js
+++ b/src/store/action-creator.js
@@ -53,4 +53,9 @@ export const setSearchHistory = list => ({
export const setPlayHistory = list => ({
type: types.SET_PLAY_HISTORY,
payload: list
+})
+
+export const setFavorite = list => ({
+ type: types.SET_FAVORITE_LIST,
+ payload: list
})
\ No newline at end of file
diff --git a/src/store/action.js b/src/store/action.js
index b973022..0c1898d 100644
--- a/src/store/action.js
+++ b/src/store/action.js
@@ -1,7 +1,7 @@
import * as actions from './action-creator'
import {playMode} from 'common/js/config'
import {shuffle} from 'common/js/util'
-import {saveSearch, deleteSearch, clearSearch, savePlay} from 'common/js/cache'
+import {saveSearch, deleteSearch, clearSearch, savePlay, saveFavorite, deleteFavorite} from 'common/js/cache'
export function setDisc(data) {
return dispatch => {
@@ -146,6 +146,18 @@ export function savePlayHistory(song) {
}
}
+export function deleteFavoriteList(song) {
+ return dispatch => {
+ dispatch(actions.setFavorite(deleteFavorite(song)))
+ }
+}
+
+export function saveFavoriteList(song) {
+ return dispatch => {
+ dispatch(actions.setFavorite(saveFavorite(song)))
+ }
+}
+
function findIndex(list, song) {
return list.findIndex((item) => {
return item.id === song.id
diff --git a/src/store/reducers.js b/src/store/reducers.js
index 87b05a6..4f51fab 100644
--- a/src/store/reducers.js
+++ b/src/store/reducers.js
@@ -96,4 +96,13 @@ export function playHistory(state = initState.playHistory, action) {
default:
return state
}
+}
+
+export function favoriteList(state = initState.favoriteList, action) {
+ switch (action.type) {
+ case types.SET_FAVORITE_LIST:
+ return [...action.payload]
+ default:
+ return state
+ }
}
\ No newline at end of file
diff --git a/src/store/state.js b/src/store/state.js
index 344d379..a5928e9 100644
--- a/src/store/state.js
+++ b/src/store/state.js
@@ -1,5 +1,5 @@
import {playMode} from 'common/js/config'
-import {loadSearch, loadPlay} from 'common/js/cache'
+import {loadSearch, loadPlay, loadFavorite} from 'common/js/cache'
const state = {
disc: {},
@@ -15,6 +15,7 @@ const state = {
},
topList: {},
searchHistory: loadSearch(),
- playHistory: loadPlay()
+ playHistory: loadPlay(),
+ favoriteList: loadFavorite()
}
export default state
\ No newline at end of file