[+] Clickable resume

This commit is contained in:
2025-11-20 22:02:41 +08:00
parent bf7d0ca142
commit d68218535d
2 changed files with 18 additions and 3 deletions
+13 -1
View File
@@ -1,10 +1,22 @@
// import { log } from 'console';
import { listMyPlaylists, listRecPlaylists } from '../lib/server/songs';
import { listMyPlaylists, listRecPlaylists, getPlaylist } from '../lib/server/songs';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params, parent }) => {
let last = undefined
const { user } = await parent()
if (user?.data?.loc) {
try {
const playlist = await getPlaylist(user.data.loc.currentPlaylistId);
if (playlist) {
last = playlist.tracks[user.data.loc.currentSongIndex];
}
} catch (e) {
console.error("Failed to load last playlist", e);
}
}
let myPlaylists = await listMyPlaylists(user)
let recPlaylists = await listRecPlaylists()
return { last, myPlaylists, recPlaylists }
+5 -2
View File
@@ -9,6 +9,9 @@
let { data }: PageProps = $props()
console.log(data.recPlaylists)
const loc = data.user.data.loc
const href = loc?.isFinished && loc?.lastResultId ? `/results/${loc.lastResultId}` : `/song/${data.last?.id}`
</script>
@@ -18,12 +21,12 @@
<div class="vbox gap-16px overflow-y-auto">
{#if data.last}
<div>
<a {href}>
<TitleHeader title="从暂停的位置继续"/>
<div class="p-content">
<SongInfo info={data.last}></SongInfo>
</div>
</div>
</a>
{/if}
<div>