changed render modes
This commit is contained in:
@@ -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()
|
||||||
|
|||||||
@@ -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"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user