Skip to content

Commit

Permalink
feat(HotList): 新增网易云音乐热歌榜
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwumm committed May 7, 2024
1 parent 61af8b2 commit 9661b47
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>今日热榜 - 汇聚全网热点,热门尽览无余</title>
<meta name="description" content="汇聚全网热点,热门尽览无余">
<meta name="keywords" content="微博热搜,抖音热点榜,bilibili热门榜,知乎热榜,百度热搜榜,今日头条热榜,稀土掘金热榜,百度贴吧热议榜,腾讯新闻热点榜,网易新闻热榜,澎湃新闻热榜,lol英雄联盟更新公告,快手热榜,历史上的今天,微信读书飙升榜">
<meta name="keywords" content="微博热搜,抖音热点榜,bilibili热门榜,知乎热榜,百度热搜榜,今日头条热榜,稀土掘金热榜,百度贴吧热议榜,腾讯新闻热点榜,网易新闻热榜,澎湃新闻热榜,lol英雄联盟更新公告,快手热榜,历史上的今天,微信读书飙升榜,豆瓣电影新片榜,网易云音乐热歌榜">
<meta name="baidu-site-verification" content="codeva-kYzuuOyYCZ" />
<!-- 百度统计 -->
<script>
Expand Down
1 change: 1 addition & 0 deletions public/netease-music.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 20 additions & 11 deletions src/components/HotContainer/HotList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @Author: 白雾茫茫丶
* @Date: 2023-10-30 16:01:49
* @LastEditors: 白雾茫茫丶<baiwumm.com>
* @LastEditTime: 2024-05-06 14:33:20
* @LastEditTime: 2024-05-07 14:51:02
*/
import 'dayjs/locale/zh-cn'

Expand Down Expand Up @@ -97,8 +97,18 @@ const HotList: FC<HotListConfig & HotListProps> = ({ value, label, tip, primaryC
<ul className={styles['hot-container']}>
{map(get(data, 'list', []), (item: HotListItem, index: number) => {
const hasWeiboLabel: boolean = eq(value, 'weibo') && item.label;
// 渲染右侧信息
const renderRight = (value: string | number) => (
<div className='hot-number' style={{
color: !isDark ? 'rgba(0, 0, 0, 0.45)' : 'inherit'
}}>{value}</div>
)
// 判断是否是历史上的今天
const isToday = value === 'today';
const isToday = eq(value, 'today');
// 判断是否是网易云音乐
const isNeteaseMusic = eq(value, 'netease-music');
// 渲染标题
const title = isNeteaseMusic ? `${item.title}${item.author}】` : item.title;
return (
<li key={item.id} className={styles['hot-container-item']} style={{ animationDelay: `${add(index, 1) * 0.1}s` }}>
<div className='hot-box'>
Expand All @@ -112,18 +122,17 @@ const HotList: FC<HotListConfig & HotListProps> = ({ value, label, tip, primaryC
</div>
<Text
className="hot-title"
ellipsis={{ tooltip: item.title }}
ellipsis={{ tooltip: title }}
onClick={() => window.open(item.url)}
>
{item.title}
{title}
</Text>
{item.hot && <div className='hot-number' style={{
color: !isDark ? 'rgba(0, 0, 0, 0.45)' : 'inherit'
}}>{formatNumber(item.hot)}</div>}
{/* 热度 */}
{item.hot && renderRight(formatNumber(item.hot))}
{/* 历史上的今天显示年份 */}
{isToday && <div className='hot-number' style={{
color: !isDark ? 'rgba(0, 0, 0, 0.45)' : 'inherit'
}}>{`${item.year}年`}</div>}
{isToday && renderRight(`${item.year}年`)}
{/* 音乐显示时长 */}
{isNeteaseMusic && item.duration && renderRight(item.duration)}
</div>
</li>
)
Expand All @@ -147,7 +156,7 @@ const HotList: FC<HotListConfig & HotListProps> = ({ value, label, tip, primaryC
const updateTime = getLocalStorageItem<UpdateTime>(LOCAL_KEY.UPDATETIME);
// 60s 内不允许刷新
const seconds = dayjs().diff(updateTime?.[value], 'second');
if (seconds >= 60) {
if (seconds >= 60 || !data?.list?.length) {
run();
} else {
messageApi.open({
Expand Down
5 changes: 5 additions & 0 deletions src/components/HotContainer/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export const hotDataSource: HotListConfig[] = [
label: '豆瓣电影',
tip: '新片榜'
},
{
value: 'netease-music',
label: '网易云音乐',
tip: '热歌榜'
}
]

/**
Expand Down
26 changes: 14 additions & 12 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,26 @@ export type HotTypes =
'kuaishou' |
'today' |
'weread' |
'douban-movic'
'douban-movic' |
'netease-music'

/**
* @description: 表单子项
* @author: 白雾茫茫丶
*/
export type HotListItem = {
id: string;
title: string;
desc: string;
pic: string;
hot: number | string;
type?: string;
year?: string;
score?: number;
url: string;
mobileUrl: string;
label?: string;
id: string; // 唯一 key
title: string; // 标题
desc: string; // 描述
pic: string; // 封面图
hot: number | string; // 热度
year?: string; // 年份(历史上的今天)
score?: number; // 评分(豆瓣电影)
author?: string; // 作者(音乐)
duration?: string; // 音乐时长
url: string; // 地址
mobileUrl: string; // 移动端地址
label?: string; // 标签(微博)
}

/**
Expand Down

0 comments on commit 9661b47

Please sign in to comment.