[+] Clickable resume
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user