Skip to content

Commit 4a894eb

Browse files
author
coderwhy
committed
完成播放功能/歌词展示等
1 parent 387265d commit 4a894eb

File tree

81 files changed

+2211
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+2211
-183
lines changed

src/assets/css/base.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ body, textarea, select, input, button {
8484
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/sprite_icon2.png) no-repeat 0 9999px;
8585
}
8686

87+
.sprite_icon3 {
88+
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/sprite_icon3.png) no-repeat 0 9999px;
89+
}
90+
8791
.sprite_button {
8892
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/sprite_button.png) no-repeat 0 9999px;
8993
}
@@ -96,6 +100,14 @@ body, textarea, select, input, button {
96100
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/sprite_table.png) no-repeat 0 9999px;
97101
}
98102

103+
.sprite_playbar {
104+
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/playbar_sprite.png) no-repeat 0 9999px;
105+
}
106+
107+
.sprite_playlist {
108+
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/playlist_sprite.png) no-repeat 0 9999px;
109+
}
110+
99111
.image_cover {
100112
position: absolute;
101113
left: 0;
@@ -105,3 +117,13 @@ body, textarea, select, input, button {
105117
text-indent: -9999px;
106118
background: url(http://github.com/..%3Cspan%20class=pl-c1%3E/%3C/span%3Eimg/sprite_cover.png) no-repeat -145px -57px;
107119
}
120+
121+
122+
.ant-message .ant-message-notice-content {
123+
position: fixed;
124+
left: 50%;
125+
transform: translateX(-50%);
126+
bottom: 60px;
127+
background-color: rgba(0, 0, 0, .5);
128+
color: #fff;
129+
}

src/assets/img/playbar_sprite.png

14.5 KB
Loading

src/assets/img/playlist_sprite.png

3.66 KB
Loading

src/assets/img/playpanel_bg.png

38 KB
Loading

src/assets/img/progress_bar.png

1.21 KB
Loading

src/assets/img/singer_sprite.png

698 Bytes
Loading

src/assets/img/sprite_icon3.png

13.5 KB
Loading

src/assets/img/wrap-bg.png

182 Bytes
Loading

src/components/pagination/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { memo } from 'react';
2+
3+
import { Pagination } from 'antd';
4+
import { PaginationWrapper } from './style';
5+
6+
export default memo(function HYPagination(props) {
7+
const { currentPage, total, onPageChange } = props;
8+
9+
// render function
10+
function itemRender(current, type, originalElement) {
11+
if (type === 'prev') {
12+
return <button className="control prev"> &lt; 上一页</button>;
13+
}
14+
if (type === 'next') {
15+
return <button className="control next">上一页 &gt;</button>;
16+
}
17+
return originalElement;
18+
}
19+
20+
return (
21+
<PaginationWrapper>
22+
<Pagination className="pagination"
23+
size="small"
24+
current={currentPage}
25+
defaultCurrent={1}
26+
total={total}
27+
pageSize={35}
28+
showSizeChanger={false}
29+
itemRender={itemRender}
30+
onChange={onPageChange} />
31+
</PaginationWrapper>
32+
)
33+
})

src/components/pagination/style.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import styled from 'styled-components';
2+
3+
export const PaginationWrapper = styled.div`
4+
.pagination {
5+
margin: 30px 0;
6+
text-align: center;
7+
8+
.control {
9+
width: 69px;
10+
height: 24px;
11+
line-height: 22px;
12+
text-align: center;
13+
border: 1px solid #ccc;
14+
border-radius: 2px;
15+
margin: 0 5px;
16+
color: #333;
17+
18+
&:disabled {
19+
color: #999;
20+
}
21+
}
22+
23+
.ant-pagination-item {
24+
border: 1px solid #ccc !important;
25+
margin: 0 5px;
26+
border-radius: 3px;
27+
28+
a {
29+
font-size: 12px;
30+
}
31+
32+
&.ant-pagination-item-active {
33+
background-color: #c20c0c;
34+
border-color: #A2161B;
35+
a {
36+
color: #fff;
37+
}
38+
}
39+
}
40+
}
41+
`
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { memo } from 'react';
2+
3+
import { OperationBarWrapper } from './style';
4+
5+
export default memo(function HYSongOperationBar(props) {
6+
const { favorTitle, shareTitle, downloadTitle, commentTitle } = props;
7+
8+
return (
9+
<OperationBarWrapper>
10+
<span className="play">
11+
<a href="/abc" className="play-icon sprite_button">
12+
<span className="play sprite_button">
13+
<i className="sprite_button"></i>
14+
<span>播放</span>
15+
</span>
16+
</a>
17+
<a href="/abc" className="add-icon sprite_button">+</a>
18+
</span>
19+
<a href="/abc" className="item sprite_button">
20+
<i className="icon favor-icon sprite_button">{favorTitle}</i>
21+
</a>
22+
<a href="/abc" className="item sprite_button">
23+
<i className="icon share-icon sprite_button">{shareTitle}</i>
24+
</a>
25+
<a href="/abc" className="item sprite_button">
26+
<i className="icon download-icon sprite_button">{downloadTitle}</i>
27+
</a>
28+
<a href="/abc" className="item sprite_button">
29+
<i className="icon comment-icon sprite_button">{commentTitle}</i>
30+
</a>
31+
</OperationBarWrapper>
32+
)
33+
})
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import styled from 'styled-components';
2+
3+
export const OperationBarWrapper = styled.div`
4+
display: flex;
5+
align-items: center;
6+
7+
.play {
8+
display: flex;
9+
align-items: center;
10+
margin-right: 5px;
11+
12+
.play-icon {
13+
display: inline-block;
14+
height: 31px;
15+
line-height: 31px;
16+
background-position: right -428px;
17+
18+
.play {
19+
color: #fff;
20+
display: flex;
21+
align-items: center;
22+
padding: 0 7px 0 8px;
23+
background-position: 0 -387px;
24+
25+
i {
26+
display: inline-block;
27+
width: 20px;
28+
height: 18px;
29+
margin: -2px 2px 0;
30+
background-position: 0 -1622px;
31+
}
32+
}
33+
}
34+
35+
.add-icon {
36+
display: inline-block;
37+
width: 31px;
38+
height: 31px;
39+
margin-left: -3px;
40+
padding-right: 0;
41+
background-position: 0 -1588px;
42+
text-indent: -9999px;
43+
}
44+
}
45+
46+
.item {
47+
display: inline-block;
48+
height: 31px;
49+
margin-right: 6px;
50+
padding-right: 5px;
51+
background-position: right -1020px;
52+
53+
.icon {
54+
display: inline-block;
55+
height: 31px;
56+
line-height: 31px;
57+
padding: 0 7px 0 28px;
58+
font-family: simsun;
59+
}
60+
61+
.favor-icon {
62+
background-position: 0 -977px;
63+
}
64+
65+
.share-icon {
66+
background-position: 0 -1225px;
67+
}
68+
69+
.download-icon {
70+
background-position: 0 -2761px;
71+
}
72+
73+
.comment-icon {
74+
background-position: 0 -1465px;
75+
}
76+
}
77+
`
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { memo } from 'react';
2+
3+
import { HeaderWrapper } from './style';
4+
5+
export default memo(function HYThemeHeaderPlayer(props) {
6+
const { title } = props;
7+
8+
return (
9+
<HeaderWrapper>
10+
<h3>{title}</h3>
11+
</HeaderWrapper>
12+
)
13+
})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import styled from 'styled-components';
2+
3+
export const HeaderWrapper = styled.div`
4+
h3 {
5+
height: 23px;
6+
margin-bottom: 20px;
7+
border-bottom: 1px solid #ccc;
8+
font-size: 12px;
9+
font-weight: 700;
10+
color: #333;
11+
}
12+
`

src/components/top-ranking/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import React, { memo } from 'react';
2+
import { useDispatch } from 'react-redux';
3+
4+
import { getSongDetailAction } from '@/pages/player/store';
25

36
import {
47
getSizeImage
@@ -9,9 +12,18 @@ import {
912
} from "./style";
1013

1114
export default memo(function HYTopRanking(props) {
15+
// props and state
1216
const { info } = props;
1317
const tracks = (info.tracks && info.tracks.slice(0, 10)) || [];
1418

19+
// redux hooks
20+
const dispatch = useDispatch();
21+
22+
// handle code
23+
const playItem = (id) => {
24+
dispatch(getSongDetailAction(id));
25+
};
26+
1527
return (
1628
<TopRankingWrapper>
1729
<div className="header">
@@ -34,6 +46,11 @@ export default memo(function HYTopRanking(props) {
3446
<div key={item.id} className="list-item">
3547
<div className="rank">{index + 1}</div>
3648
<div className="name">{item.name}</div>
49+
<div className="operate">
50+
<button className="sprite_02 btn play" onClick={e => playItem(item.id)}></button>
51+
<button className="sprite_icon2 btn addto"></button>
52+
<button className="sprite_02 btn favor"></button>
53+
</div>
3754
</div>
3855
)
3956
})

src/components/top-ranking/style.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const TopRankingWrapper = styled.div`
4343
4444
.list {
4545
.list-item {
46+
position: relative;
4647
display: flex;
4748
align-items: center;
4849
height: 32px;
@@ -61,6 +62,41 @@ export const TopRankingWrapper = styled.div`
6162
.name {
6263
color: #000;
6364
}
65+
66+
.operate {
67+
position: absolute;
68+
display: flex;
69+
align-items: center;
70+
right: 0;
71+
display: none;
72+
73+
.btn {
74+
width: 17px;
75+
height: 17px;
76+
margin-right: 8px;
77+
cursor: pointer;
78+
}
79+
80+
.play {
81+
background-position: -267px -268px;
82+
}
83+
84+
.addto {
85+
position: relative;
86+
top: 2px;
87+
background-position: 0 -700px;
88+
}
89+
90+
.favor {
91+
background-position: -297px -268px;
92+
}
93+
}
94+
95+
&:hover {
96+
.operate {
97+
display: block;
98+
}
99+
}
64100
}
65101
}
66102

src/pages/discover/c-pages/album/c-cpns/top-album/index.js

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
import React, { memo, useEffect } from 'react';
2-
import { useDispatch, useSelector } from 'react-redux';
1+
import React, { memo, useEffect, useState } from 'react';
2+
import { useDispatch, useSelector, shallowEqual } from 'react-redux';
33

44
import { getTopAlbumsAction } from '../../store/actionCreators';
55

66
import HYThemeHeaderNormal from "@/components/theme-header-normal";
77
import HYAlbumCover from "@/components/album-cover";
8+
import HYPagination from '@/components/pagination';
89
import {
910
TopAlbumWrapper
1011
} from './style';
1112

1213
export default memo(function HYTopAlbum() {
13-
const { topAlbums } = useSelector(state => ({
14-
topAlbums: state.getIn(["album", "topAlbums"])
15-
}))
14+
const [currentPage, setCurrentPage] = useState(1);
15+
16+
const { topAlbums, total } = useSelector(state => ({
17+
topAlbums: state.getIn(["album", "topAlbums"]),
18+
total: state.getIn(["album", "topTotal"])
19+
}), shallowEqual);
1620
const dispatch = useDispatch();
1721

1822
useEffect(() => {
19-
dispatch(getTopAlbumsAction());
23+
dispatch(getTopAlbumsAction(1));
2024
}, [dispatch]);
2125

26+
27+
const onPageChange = (page, pageSize) => {
28+
setCurrentPage(page);
29+
dispatch(getTopAlbumsAction(page))
30+
}
31+
2232
return (
2333
<TopAlbumWrapper>
2434
<HYThemeHeaderNormal title="全部新碟" />
@@ -33,6 +43,10 @@ export default memo(function HYTopAlbum() {
3343
})
3444
}
3545
</div>
46+
<HYPagination currentPage={currentPage}
47+
total={total}
48+
pageSize={30}
49+
onPageChange={onPageChange}/>
3650
</TopAlbumWrapper>
3751
)
3852
})

0 commit comments

Comments
 (0)