diff --git a/src/components/IconButton.svelte b/src/components/IconButton.svelte index 0e6a0e9..d13b6cf 100644 --- a/src/components/IconButton.svelte +++ b/src/components/IconButton.svelte @@ -2,6 +2,6 @@ let { icon, ...rest } = $props(); - \ No newline at end of file diff --git a/src/components/SongInfo.svelte b/src/components/SongInfo.svelte index e69de29..06bf908 100644 --- a/src/components/SongInfo.svelte +++ b/src/components/SongInfo.svelte @@ -0,0 +1,15 @@ + + +
+ Album Art +
+
{info.name}
+
+
{info.artists.map(a => a.name).join(", ")} - {info.album}
+
+
+
\ No newline at end of file diff --git a/src/components/TitleHeader.svelte b/src/components/TitleHeader.svelte new file mode 100644 index 0000000..96c3e56 --- /dev/null +++ b/src/components/TitleHeader.svelte @@ -0,0 +1,10 @@ + + +
+
{title}
+ +
\ No newline at end of file diff --git a/src/components/appbar/AppBar.svelte b/src/components/appbar/AppBar.svelte index b4f426b..d53ec2f 100644 --- a/src/components/appbar/AppBar.svelte +++ b/src/components/appbar/AppBar.svelte @@ -19,4 +19,4 @@ {#if settings} {/if} - + \ No newline at end of file diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts new file mode 100644 index 0000000..605b07f --- /dev/null +++ b/src/routes/+page.server.ts @@ -0,0 +1,8 @@ +// import { log } from 'console'; +import { getSongMeta, parseBrief } from '../shared/songs'; +import type { PageServerLoad } from './$types'; + +export const load: PageServerLoad = async ({ params }) => { + let last = parseBrief(await getSongMeta(25723366)) + return { last } +} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ef7c6aa..7327ba3 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,7 +1,29 @@ - alert('Account clicked')} settings={() => alert('Settings clicked')} /> + +
+ {#if data.last} +
+ +
+ +
+
+ {/if} + +
+ +
+ 最近播放的列表 +
+
+
\ No newline at end of file diff --git a/src/routes/app.sass b/src/routes/app.sass index c81e989..cae1e56 100644 --- a/src/routes/app.sass +++ b/src/routes/app.sass @@ -4,4 +4,25 @@ body margin: 0 - background: rgb(var(--m3-scheme-background)) \ No newline at end of file + background: rgb(var(--m3-scheme-background)) + +.hbox + display: flex + flex-direction: row + align-items: center + +.vbox + display: flex + flex-direction: column + +.vcbox + @extend .vbox + align-items: center + +.cbox + display: flex + justify-content: center + align-items: center + +.p-content + padding: 0 16px \ No newline at end of file diff --git a/src/shared/songs.ts b/src/shared/songs.ts index 696d1c7..b527a79 100644 --- a/src/shared/songs.ts +++ b/src/shared/songs.ts @@ -54,8 +54,14 @@ const getPlaylistRaw = cached( await fs.writeFile(p, JSON.stringify(track), 'utf-8') } return pl - } -) + }) + +export const getSongMeta = cached( + async (songId: number) => path.join('data', 'songs', `${songId}`, 'meta.json'), + async (songId: number) => { + const detail = await ne.song_detail({ ids: songId.toString() }) + return detail.body.songs[0] + }) export interface NeteaseSongBrief { id: number @@ -66,20 +72,22 @@ export interface NeteaseSongBrief { artists: { id: number, name: string }[] } +export const parseBrief = (songData: any): NeteaseSongBrief => ({ + id: songData.id, + name: songData.name, + album: songData.al.name, + albumId: songData.al.id, + albumPic: songData.al.picUrl, + artists: songData.ar.map((ar: any) => ({ id: ar.id, name: ar.name })) +}) + /** * Get a list of songs from a playlist reference. */ export async function getSongsFromPlaylist(ref: string): Promise { const playlistId = parsePlaylistRef(ref) const plData = await getPlaylistRaw({ id: playlistId }) - return plData.playlist.tracks.map((track: any) => ({ - id: track.id, - name: track.name, - album: track.al.name, - albumId: track.al.id, - albumPic: track.al.picUrl, - artists: track.ar.map((ar: any) => ({ id: ar.id, name: ar.name })) - })) + return plData.playlist.tracks.map(parseBrief) } interface NeteaseLyricsResponse { lrc: { lyric: string } } @@ -98,4 +106,4 @@ export const getLyricsProcessed = cached( ) // console.log((await getSongsFromPlaylist('580208139')).length) -console.log(await getLyricsProcessed(25723366)) \ No newline at end of file +// console.log(await getLyricsProcessed(25723366)) \ No newline at end of file diff --git a/uno.config.ts b/uno.config.ts index c8749bf..8cf26ea 100644 --- a/uno.config.ts +++ b/uno.config.ts @@ -105,11 +105,6 @@ export default defineConfig({ })] ], shortcuts: { - // Azalea's shortcuts - 'hbox': 'flex flex-row items-center', - 'vbox': 'flex flex-col items-center', - 'cbox': 'flex justify-center items-center', - // Marina 'form-error': 'text-3.5 font-medium text-destructive', 'form-warning': 'text-3.5 font-medium text-warning',