diff --git a/src/routes/song/[id]/+page.server.ts b/src/routes/song/[id]/+page.server.ts deleted file mode 100644 index d4038ca..0000000 --- a/src/routes/song/[id]/+page.server.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { PageServerLoad } from './$types' -import { getLyricsProcessed, getSongRaw, getSongUrl } from "$lib/server/songs.ts"; - -export const load: PageServerLoad = async ({ params }) => { - const songId = +params.id - const song = await getSongRaw(songId) - const lrc = await getLyricsProcessed(songId) - // const audioUrl = await getSongUrl(songId) - return { song, lrc, audioUrl: undefined } -} \ No newline at end of file diff --git a/src/routes/song/[id]/play/+page.server.ts b/src/routes/song/[id]/play/+page.server.ts new file mode 100644 index 0000000..a95102a --- /dev/null +++ b/src/routes/song/[id]/play/+page.server.ts @@ -0,0 +1,15 @@ +import type { PageServerLoad } from '../$types' +import { getLyricsProcessed, getSongRaw, getSongUrl, checkLyricsProcessed } from "$lib/server/songs.ts"; +import { redirect } from '@sveltejs/kit'; + +export const load: PageServerLoad = async ({ params }) => { + const songId = +params.id + const song = await getSongRaw(songId) + const hasLrc = await checkLyricsProcessed(songId) + + if (!hasLrc) throw redirect(302, `/song/${songId}/prepare`) + + const lrc = await getLyricsProcessed(songId) + // const audioUrl = await getSongUrl(songId) + return { song, lrc, audioUrl: undefined } +} \ No newline at end of file diff --git a/src/routes/song/[id]/+page.svelte b/src/routes/song/[id]/play/+page.svelte similarity index 96% rename from src/routes/song/[id]/+page.svelte rename to src/routes/song/[id]/play/+page.svelte index 3685ded..c1369e9 100644 --- a/src/routes/song/[id]/+page.svelte +++ b/src/routes/song/[id]/play/+page.svelte @@ -1,17 +1,18 @@