Skip to content

Commit f17b4b7

Browse files
author
coderwhy
committed
增加了一些交互,解决了一些bug
1 parent 583e850 commit f17b4b7

File tree

11 files changed

+327
-72
lines changed

11 files changed

+327
-72
lines changed

src/assets/css/base.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,8 @@ body, textarea, select, input, button {
127127
background-color: rgba(0, 0, 0, .5);
128128
color: #fff;
129129
}
130+
131+
span:hover.link {
132+
text-decoration: underline;
133+
cursor: pointer;
134+
}

src/components/theme-header-rcm/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import React, {memo} from 'react';
22
import PropTypes from "prop-types";
33

4+
import { Link } from 'react-router-dom';
45
import {
56
HeaderWrapper
67
} from "./style";
78

89
const HYThemeHeaderRCM = memo(function(props) {
9-
const { title, keywords } = props;
10+
const { title, keywords, moreLink, keywordClick } = props;
1011

1112
return (
1213
<HeaderWrapper className="sprite_02">
1314
<div className="left">
1415
<h3 className="title">{title}</h3>
1516
<div className="keyword">
1617
{
17-
keywords.map((item) => {
18+
keywords.map((item, index) => {
1819
return (
1920
<div className="item" key={item}>
20-
<a href="/todo">{item}</a>
21+
<span className="link" onClick={e => keywordClick(item)}>{item}</span>
2122
<span className="divider">|</span>
2223
</div>
2324
)
@@ -26,7 +27,7 @@ const HYThemeHeaderRCM = memo(function(props) {
2627
</div>
2728
</div>
2829
<div className="right">
29-
<a href="todo">更多</a>
30+
<Link to={moreLink}>更多</Link>
3031
<i className="icon sprite_02"></i>
3132
</div>
3233
</HeaderWrapper>

src/components/top-ranking/index.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,61 @@
11
import React, { memo } from 'react';
22
import { useDispatch } from 'react-redux';
33

4+
import { getSizeImage } from '@/utils/format-utils';
45
import { getSongDetailAction } from '@/pages/player/store';
56

6-
import {
7-
getSizeImage
8-
} from "@/utils/format-utils";
9-
10-
import {
11-
TopRankingWrapper
12-
} from "./style";
7+
import { TopRankingWrapper } from './style';
138

149
export default memo(function HYTopRanking(props) {
1510
// props and state
1611
const { info } = props;
17-
const tracks = (info.tracks && info.tracks.slice(0, 10)) || [];
12+
const { tracks = [] } = info;
1813

1914
// redux hooks
2015
const dispatch = useDispatch();
2116

22-
// handle code
23-
const playItem = (id) => {
24-
dispatch(getSongDetailAction(id));
25-
};
17+
// other handle
18+
const playMusic = (item) => {
19+
dispatch(getSongDetailAction(item.id));
20+
}
2621

2722
return (
2823
<TopRankingWrapper>
2924
<div className="header">
3025
<div className="image">
31-
<img src={getSizeImage(info.coverImgUrl, 80)} alt="" />
32-
<a href="/abc" className="image_cover">top</a>
26+
<img src={getSizeImage(info.coverImgUrl)} alt="" />
27+
<a href="/todo" className="image_cover">ranking</a>
3328
</div>
3429
<div className="info">
35-
<h3>{info.name}</h3>
36-
<div className="operate">
37-
<a href="/play" className="sprite_02 btn play">播放</a>
38-
<a href="/favor" className="sprite_02 btn favor">收藏</a>
30+
<a href="/todo">{info.name}</a>
31+
<div>
32+
<button className="btn play sprite_02"></button>
33+
<button className="btn favor sprite_02"></button>
3934
</div>
4035
</div>
4136
</div>
4237
<div className="list">
4338
{
44-
tracks.map((item, index) => {
39+
tracks.slice(0, 10).map((item, index) => {
4540
return (
4641
<div key={item.id} className="list-item">
4742
<div className="rank">{index + 1}</div>
48-
<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>
43+
<div className="info">
44+
<span className="name text-nowrap">{item.name}</span>
45+
<div className="operate">
46+
<button className="btn sprite_02 play"
47+
onClick={e => playMusic(item)}></button>
48+
<button className="btn sprite_icon2 addto"></button>
49+
<button className="btn sprite_02 favor"></button>
50+
</div>
5351
</div>
5452
</div>
5553
)
5654
})
5755
}
5856
</div>
5957
<div className="footer">
60-
<a href="/abc">查看全部&gt;</a>
58+
<a href="/todo">查看全部 &gt;</a>
6159
</div>
6260
</TopRankingWrapper>
6361
)

src/components/top-ranking/style.js

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,19 @@ export const TopRankingWrapper = styled.div`
2323
.info {
2424
margin: 5px 0 0 10px;
2525
26+
a {
27+
font-size: 14px;
28+
color: #333;
29+
font-weight: 700;
30+
}
31+
2632
.btn {
2733
display: inline-block;
2834
text-indent: -9999px;
2935
width: 22px;
3036
height: 22px;
3137
margin: 8px 10px 0 0;
38+
cursor: pointer;
3239
}
3340
3441
.play {
@@ -59,39 +66,49 @@ export const TopRankingWrapper = styled.div`
5966
font-size: 16px;
6067
}
6168
62-
.name {
69+
.info {
6370
color: #000;
64-
}
65-
66-
.operate {
67-
position: absolute;
71+
width: 170px;
72+
height: 17px;
73+
line-height: 17px;
6874
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-
}
75+
justify-content: space-between;
7976
80-
.play {
81-
background-position: -267px -268px;
77+
.name {
78+
flex: 1;
8279
}
8380
84-
.addto {
85-
position: relative;
86-
top: 2px;
87-
background-position: 0 -700px;
88-
}
89-
90-
.favor {
91-
background-position: -297px -268px;
81+
.operate {
82+
display: flex;
83+
align-items: center;
84+
display: none;
85+
width: 82px;
86+
87+
.btn {
88+
width: 17px;
89+
height: 17px;
90+
margin-left: 8px;
91+
cursor: pointer;
92+
}
93+
94+
.play {
95+
background-position: -267px -268px;
96+
}
97+
98+
.addto {
99+
position: relative;
100+
top: 2px;
101+
background-position: 0 -700px;
102+
}
103+
104+
.favor {
105+
background-position: -297px -268px;
106+
}
92107
}
93108
}
94109
110+
111+
95112
&:hover {
96113
.operate {
97114
display: block;

src/pages/discover/c-pages/recommend/c-cpns/hot-recommend/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import React, { useEffect, memo } from 'react';
1+
import React, { useEffect, memo, useCallback } from 'react';
22
import { useDispatch, useSelector, shallowEqual } from "react-redux";
3+
import { useHistory } from 'react-router-dom';
34

45
import {
56
getRecommend
@@ -18,14 +19,22 @@ export default memo(function HYHotRecommend() {
1819
recommends: state.getIn(["recommend", "hotRecommends"])
1920
}), shallowEqual);
2021
const dispatch = useDispatch();
22+
const history = useHistory();
2123

2224
useEffect(() => {
2325
dispatch(getRecommend())
2426
}, [dispatch]);
2527

28+
const keywordClick = useCallback((keyword) => {
29+
history.push({pathname: "/discover/songs", cat: keyword});
30+
}, [history]);
31+
2632
return (
2733
<RecommendWrapper>
28-
<HYThemeHeaderRCM title="热门推荐" keywords={["华语", "流行", "摇滚", "民谣", "电子"]}/>
34+
<HYThemeHeaderRCM title="热门推荐"
35+
keywords={["华语", "流行", "摇滚", "民谣", "电子"]}
36+
moreLink="/discover/songs"
37+
keywordClick={keywordClick}/>
2938
<div className="recommend-list">
3039
{
3140
state.recommends.slice(0, 8).map((item, index) => {

src/pages/discover/c-pages/recommend/c-cpns/new-album/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default memo(function HYNewAlbum(props) {
2727

2828
return (
2929
<AlbumWrapper>
30-
<HYThemeHeaderRCM title="新碟上架" />
30+
<HYThemeHeaderRCM title="新碟上架" moreLink="/discover/album"/>
3131
<div className="content">
3232
<div className="arrow arrow-left sprite_02"
3333
onClick={e => carouselRef.current.prev()}></div>

src/pages/discover/c-pages/recommend/c-cpns/ranking-list/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default memo(function HYRankingList() {
2929

3030
return (
3131
<RankingWrapper>
32-
<HYThemeHeaderRCM title="榜单" />
32+
<HYThemeHeaderRCM title="榜单" moreLink="/discover/ranking"/>
3333
<div className="tops">
3434
<HYTopRanking info={state.topUpList}/>
3535
<HYTopRanking info={state.topNewList}/>

src/pages/discover/c-pages/songs/c-cpns/songs-category/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default memo(function HYSongsCategory() {
2626
<CategoryWrapper>
2727
<div className="arrow sprite_icon"></div>
2828
<div className="all">
29-
<a href="/#" onClick={e => selectCategory("全部")}>全部风格</a>
29+
<span className="link" onClick={e => selectCategory("全部")}>全部风格</span>
3030
</div>
3131
<div className="category">
3232
{
@@ -42,7 +42,7 @@ export default memo(function HYSongsCategory() {
4242
item.subs.map(sItem => {
4343
return (
4444
<div className="item" key={sItem.name}>
45-
<a href={() => false} onClick={e => selectCategory(sItem.name)}>{sItem.name}</a>
45+
<span className="link" onClick={e => selectCategory(sItem.name)}>{sItem.name}</span>
4646
<span className="divider">|</span>
4747
</div>
4848
)

src/pages/discover/c-pages/songs/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import React, { useEffect, memo } from 'react';
22
import { useDispatch } from "react-redux";
3+
import { useLocation } from 'react-router-dom';
34

45
import {
56
getCategory,
6-
getSongList
7+
getSongList,
8+
changeCurrentCategoryAction
79
} from "./store/actionCreators";
810

911
import HYSongsHeader from "./c-cpns/songs-header";
@@ -15,6 +17,11 @@ import {
1517
export default memo(function HYSongs() {
1618
// redux
1719
const dispatch = useDispatch();
20+
const cat = useLocation().cat;
21+
22+
useEffect(() => {
23+
dispatch(changeCurrentCategoryAction(cat));
24+
}, [dispatch, cat]);
1825

1926
// hooks
2027
useEffect(() => {

0 commit comments

Comments
 (0)