changed render modes

This commit is contained in:
2026-01-29 21:42:56 +00:00
parent 6a1eef0f76
commit 263ec699ad
4 changed files with 23 additions and 5 deletions

View File

@@ -6,6 +6,9 @@
useHead({ useHead({
title: "Youtube 2 MP3" title: "Youtube 2 MP3"
}) })
definePageMeta({
prerender: true // HTML prerender (faster)
})
const { loggedIn } = useUserSession() const { loggedIn } = useUserSession()
const conf = useRuntimeConfig() const conf = useRuntimeConfig()

View File

@@ -6,11 +6,19 @@ import urlJoin from 'url-join'
useHead({ useHead({
title: "Login" title: "Login"
}) })
definePageMeta({
ssr: false // CSR
})
const toast = useToast() const toast = useToast()
const config = useRuntimeConfig() const config = useRuntimeConfig()
// animation & status refs
const wrong_login = ref(false) const wrong_login = ref(false)
const login_pending = ref(false)
// variable of timeout type
let wrong_login_timeout : ReturnType<typeof setTimeout>
const fields: AuthFormField[] = [{ const fields: AuthFormField[] = [{
name: 'email', name: 'email',
@@ -41,8 +49,12 @@ const schema = z.object({
type Schema = z.output<typeof schema> type Schema = z.output<typeof schema>
function onSubmit(payload: FormSubmitEvent<Schema>) { async function onSubmit(payload: FormSubmitEvent<Schema>) {
return $fetch("/login", { clearTimeout(wrong_login_timeout); // cancel the timeout
wrong_login.value = false // hide it if it was
login_pending.value = true // mark it as pending
await $fetch("/login", {
method: "POST", method: "POST",
body: { body: {
email: payload.data.email, email: payload.data.email,
@@ -50,12 +62,14 @@ function onSubmit(payload: FormSubmitEvent<Schema>) {
remember: payload.data.remember || false remember: payload.data.remember || false
} }
}).then((r) => { }).then((r) => {
login_pending.value = false
navigateTo(useBasedPath("/"), { external: true}) navigateTo(useBasedPath("/"), { external: true})
}).catch((err) => { }).catch((err) => {
if(err.data.statusCode == 401) { if(err.data.statusCode == 401) {
login_pending.value = false
wrong_login.value = true; wrong_login.value = true;
// show for 5 seconds // show for 5 seconds
setTimeout(() => wrong_login.value = false, 5000); wrong_login_timeout = setTimeout(() => wrong_login.value = false, 5000);
} }
}) })
} }
@@ -73,7 +87,7 @@ function onSubmit(payload: FormSubmitEvent<Schema>) {
label: 'Login', label: 'Login',
class: 'rounded-full', class: 'rounded-full',
variant: 'soft', variant: 'soft',
loadingAuto: true loading: login_pending
}" }"
@submit="onSubmit" @submit="onSubmit"
> >

View File

@@ -8,7 +8,7 @@
definePageMeta({ definePageMeta({
layout: "settings", layout: "settings",
middleware: ["login-required"] ssr: false, // force CSR
}) })
const toast = useToast() const toast = useToast()
const conf = useRuntimeConfig() const conf = useRuntimeConfig()

View File

@@ -9,6 +9,7 @@
definePageMeta({ definePageMeta({
layout: "settings", layout: "settings",
ssr: false // force CSR
}) })
const loading_btn = ref(false) const loading_btn = ref(false)
const toast = useToast() const toast = useToast()