From 9d1102c1b3ed43cf1011c02646fa609771b674e9 Mon Sep 17 00:00:00 2001
From: mackt <1033530438@qq.com>
Date: Tue, 26 Mar 2024 13:34:25 +0800
Subject: [PATCH] feat: add component (AudioPlayer)
---
public/img/audio-player/next.svg | 4 ++
public/img/audio-player/pause.svg | 4 ++
public/img/audio-player/random.svg | 4 ++
public/img/audio-player/scale.svg | 4 ++
src/app/layout.tsx | 12 ++--
src/app/music/page.tsx | 0
src/app/page.tsx | 23 +-------
src/components/AudioPlayer/Player.tsx | 75 ++++++++++++++++++++++++
src/components/AudioPlayer/PlayerBar.tsx | 38 ++++++++++++
src/components/Music/Full.tsx | 0
src/components/index.ts | 4 ++
11 files changed, 141 insertions(+), 27 deletions(-)
create mode 100644 public/img/audio-player/next.svg
create mode 100644 public/img/audio-player/pause.svg
create mode 100644 public/img/audio-player/random.svg
create mode 100644 public/img/audio-player/scale.svg
create mode 100644 src/app/music/page.tsx
create mode 100644 src/components/AudioPlayer/Player.tsx
create mode 100644 src/components/AudioPlayer/PlayerBar.tsx
create mode 100644 src/components/Music/Full.tsx
diff --git a/public/img/audio-player/next.svg b/public/img/audio-player/next.svg
new file mode 100644
index 0000000..84b4d94
--- /dev/null
+++ b/public/img/audio-player/next.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/public/img/audio-player/pause.svg b/public/img/audio-player/pause.svg
new file mode 100644
index 0000000..443d1c7
--- /dev/null
+++ b/public/img/audio-player/pause.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/public/img/audio-player/random.svg b/public/img/audio-player/random.svg
new file mode 100644
index 0000000..7ded78b
--- /dev/null
+++ b/public/img/audio-player/random.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/public/img/audio-player/scale.svg b/public/img/audio-player/scale.svg
new file mode 100644
index 0000000..69ebc75
--- /dev/null
+++ b/public/img/audio-player/scale.svg
@@ -0,0 +1,4 @@
+
+
+
+
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 0c4ffb4..a3af28f 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,7 +1,6 @@
-import { Header, Footer } from '@/components';
+import { Header, Footer, PlayerBar } from '@/components';
import type { Metadata, Viewport } from 'next';
-
import './globals.css';
export const metadata: Metadata = {
@@ -21,9 +20,12 @@ export const viewport: Viewport = {
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
return (
-
-
{children}
-
+
+
+ {children}
+
+
+
);
}
diff --git a/src/app/music/page.tsx b/src/app/music/page.tsx
new file mode 100644
index 0000000..e69de29
diff --git a/src/app/page.tsx b/src/app/page.tsx
index 6ee96f9..f98e4c3 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,24 +1,3 @@
-import { useState, useEffect } from 'react';
-
-import { TagCategory } from '@/components';
-
-import { getTagName } from '@/store';
-
export default function Home() {
- return (
-
- {/* 左侧 */}
-
- {/* category */}
-
- {/* 期刊列表 */}
-
-
- {/* 右侧 */}
-
-
- );
+ return ;
}
diff --git a/src/components/AudioPlayer/Player.tsx b/src/components/AudioPlayer/Player.tsx
new file mode 100644
index 0000000..1a1247d
--- /dev/null
+++ b/src/components/AudioPlayer/Player.tsx
@@ -0,0 +1,75 @@
+'use client';
+import { useState } from 'react';
+
+import Image from 'next/image';
+
+export default function AudioPlayer({ className }: { className?: string }) {
+ const [curTime, setCurTime] = useState('00:00');
+ const [totalTime, setTotalTime] = useState('00:00');
+
+ return (
+
+ {/* cover */}
+
+
+
+
+ {/* title & author */}
+
+ {/* 改成滚动的 */}
+
+ {'Ferrum Aeternum'}
+
+ {/* 改成滚动的 */}
+
+ {'Ensiferum/mmmmsa'}
+
+
+
+ {/* progress bar */}
+
+ {/* bar */}
+
+ {/* black */}
+
+ {/* gery */}
+
+ {/* point */}
+
+
+ {/* time */}
+
+ {curTime}
+ {` / ${totalTime}`}
+
+
+
+ {/* control */}
+
+
+ {/* 随机播放 */}
+
+
+ {/* 上一首 */}
+
+
+
+ {/* 播放/暂停 */}
+
+ {/* */}
+
+
+ {/* 下一首 */}
+
+
+
+
+
+ );
+}
diff --git a/src/components/AudioPlayer/PlayerBar.tsx b/src/components/AudioPlayer/PlayerBar.tsx
new file mode 100644
index 0000000..755c3b0
--- /dev/null
+++ b/src/components/AudioPlayer/PlayerBar.tsx
@@ -0,0 +1,38 @@
+'use client';
+import { useEffect, useState } from 'react';
+
+import Player from './Player';
+
+export default function PlayerBar({ className }: { className?: string }) {
+ let oldScrollY: number = 0;
+ function handleScroll() {
+ if (window.scrollY > oldScrollY) {
+ // 向下滚动
+ // if (oldScrollY < 0) return;
+ setPositionBottom(-130);
+ } else {
+ // 向上滚动
+ // if (oldScrollY > 0) return;
+ setPositionBottom(0);
+ }
+ oldScrollY = window.scrollY;
+ }
+
+ useEffect(() => {
+ window.addEventListener('scroll', handleScroll);
+ return () => {
+ window.removeEventListener('scroll', handleScroll);
+ };
+ });
+
+ const [positionBottom, setPositionBottom] = useState(0);
+
+ return (
+
+ );
+}
diff --git a/src/components/Music/Full.tsx b/src/components/Music/Full.tsx
new file mode 100644
index 0000000..e69de29
diff --git a/src/components/index.ts b/src/components/index.ts
index f916ce5..7b1519a 100644
--- a/src/components/index.ts
+++ b/src/components/index.ts
@@ -19,3 +19,7 @@ export { default as HotJournalList } from './Journal/HotJournalList';
// Common
export { default as Input } from './common/Input';
export { default as Button } from './common/Button';
+
+// Audio Player
+export { default as PlayerBar } from './AudioPlayer/PlayerBar';
+export { default as AudioPlayer } from './AudioPlayer/Player';