From 800e0b7360a6bc2ed59bd42af801fe35548df9f0 Mon Sep 17 00:00:00 2001 From: alger Date: Wed, 11 Sep 2024 16:29:43 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E5=AE=8C=E5=96=84=E6=AD=8C?= =?UTF-8?q?=E5=8D=95=E5=88=97=E8=A1=A8=E7=BB=84=E4=BB=B6=20=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E6=BB=9A=E5=8A=A8=E5=8A=A0=E8=BD=BD=E6=9B=B4=E5=A4=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 2 + src/components/MusicList.vue | 106 ++++++++++++++++++++++++++++++++--- src/utils/index.ts | 17 ++++-- src/views/list/index.vue | 1 + src/views/user/index.vue | 2 +- 5 files changed, 113 insertions(+), 15 deletions(-) diff --git a/components.d.ts b/components.d.ts index c777cfd..326b305 100644 --- a/components.d.ts +++ b/components.d.ts @@ -17,6 +17,7 @@ declare module 'vue' { NDropdown: typeof import('naive-ui')['NDropdown'] NEllipsis: typeof import('naive-ui')['NEllipsis'] NImage: typeof import('naive-ui')['NImage'] + NInfiniteScroll: typeof import('naive-ui')['NInfiniteScroll'] NInput: typeof import('naive-ui')['NInput'] NLayout: typeof import('naive-ui')['NLayout'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] @@ -25,6 +26,7 @@ declare module 'vue' { NSlider: typeof import('naive-ui')['NSlider'] NSwitch: typeof import('naive-ui')['NSwitch'] NTooltip: typeof import('naive-ui')['NTooltip'] + NVirtualList: typeof import('naive-ui')['NVirtualList'] PlayBottom: typeof import('./src/components/common/PlayBottom.vue')['default'] PlayListsItem: typeof import('./src/components/common/PlayListsItem.vue')['default'] PlaylistType: typeof import('./src/components/PlaylistType.vue')['default'] diff --git a/src/components/MusicList.vue b/src/components/MusicList.vue index 33645e0..35d9cc3 100644 --- a/src/components/MusicList.vue +++ b/src/components/MusicList.vue @@ -6,23 +6,41 @@ :drawer-style="{ backgroundColor: 'transparent' }" >
- +
+ + +
{{ name }}
- -
+ +
+
加载更多...
+ +
@@ -31,6 +49,7 @@ diff --git a/src/utils/index.ts b/src/utils/index.ts index 9108968..8307df8 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -28,16 +28,21 @@ export const secondToMinute = (s: number) => { }; // 格式化数字 千,万, 百万, 千万,亿 +const units = [ + { value: 1e8, symbol: '亿' }, + { value: 1e4, symbol: '万' }, +]; + export const formatNumber = (num: string | number) => { num = Number(num); - if (num < 10000) { - return num; + for (let i = 0; i < units.length; i++) { + if (num >= units[i].value) { + return `${(num / units[i].value).toFixed(1)}${units[i].symbol}`; + } } - if (num < 100000000) { - return `${(num / 10000).toFixed(1)}万`; - } - return `${(num / 100000000).toFixed(1)}亿`; + return num.toString(); }; + const windowData = window as any; export const getIsMc = () => { if (!windowData.electron) { diff --git a/src/views/list/index.vue b/src/views/list/index.vue index 2d00481..b31b52f 100644 --- a/src/views/list/index.vue +++ b/src/views/list/index.vue @@ -101,6 +101,7 @@ watch( v-model:loading="listLoading" :name="recommendItem?.name || ''" :song-list="listDetail?.playlist.tracks || []" + :list-info="listDetail?.playlist" />
diff --git a/src/views/user/index.vue b/src/views/user/index.vue index f52520f..fda4dc5 100644 --- a/src/views/user/index.vue +++ b/src/views/user/index.vue @@ -145,7 +145,7 @@ const handlePlay = () => { - +