🎨 Prettier formats the code
All checks were successful
Gitea Build Action / build-go (push) Successful in 24s
Gitea Build Action / build-nuxt (push) Successful in 10m0s

This commit is contained in:
Daniel Svitan 2025-06-05 11:54:09 +02:00
parent f3d43bbd65
commit 48e433ff1e
9 changed files with 85 additions and 145 deletions

View File

@ -1,75 +0,0 @@
# Nuxt Minimal Starter
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
```
## Development Server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm build
# yarn
yarn build
# bun
bun run build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm preview
# yarn
yarn preview
# bun
bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

View File

@ -1,6 +1,6 @@
<template> <template>
<UApp> <UApp>
<NuxtPage/> <NuxtPage />
</UApp> </UApp>
</template> </template>

View File

@ -1,3 +1,3 @@
export function useToken() { export function useToken() {
return useCookie<string | undefined>("token") return useCookie<string | undefined>("token");
} }

View File

@ -1,6 +1,6 @@
// https://nuxt.com/docs/api/configuration/nuxt-config // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({ export default defineNuxtConfig({
compatibilityDate: '2025-05-15', compatibilityDate: "2025-05-15",
devtools: { enabled: true }, devtools: { enabled: true },
modules: ['@nuxt/icon', '@nuxt/ui', '@nuxtjs/tailwindcss'] modules: ["@nuxt/icon", "@nuxt/ui", "@nuxtjs/tailwindcss"],
}) });

View File

@ -1,16 +1,24 @@
<template> <template>
<main class="flex items-center justify-center min-w-screen min-h-screen"> <main class="flex items-center justify-center min-w-screen min-h-screen">
<UButton icon="material-symbols:lock" size="xl" color="primary" variant="solid">Lock</UButton> <UButton
icon="material-symbols:lock"
size="xl"
color="primary"
variant="solid"
>
Lock
</UButton>
</main> </main>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
const token = useToken() const token = useToken();
const locked = true;
onMounted(() => { onMounted(() => {
if (!token.value) { if (!token.value) {
return navigateTo("/token") return navigateTo("/token");
} }
console.log(token.value) console.log(token.value);
}) });
</script> </script>

View File

@ -1,50 +1,57 @@
<template> <template>
<main class="flex items-center justify-center min-w-screen min-h-screen"> <main class="flex items-center justify-center min-w-screen min-h-screen">
<UForm :schema="schema" :state="state" @submit="onSubmit" class="flex flex-col items-end justify-center gap-y-2"> <UForm
:schema="schema"
:state="state"
@submit="onSubmit"
class="flex flex-col items-end justify-center gap-y-2"
>
<UFormField label="Token" name="token" size="xl" required> <UFormField label="Token" name="token" size="xl" required>
<UInput v-model="state.token" placeholder="Your token..." size="xl"/> <UInput
v-model="state.token"
placeholder="Your token..."
size="xl"
/>
</UFormField> </UFormField>
<UButton type="submit" size="xl"> <UButton type="submit" size="xl"> Submit </UButton>
Submit
</UButton>
</UForm> </UForm>
</main> </main>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import * as v from "valibot" import * as v from "valibot";
import type { FormSubmitEvent } from "@nuxt/ui" import type { FormSubmitEvent } from "@nuxt/ui";
const token = useToken() const token = useToken();
const schema = v.object({ const schema = v.object({
token: v.pipe(v.string(), v.nonEmpty("Please enter your token")) token: v.pipe(v.string(), v.nonEmpty("Please enter your token")),
}) });
type Schema = v.InferOutput<typeof schema> type Schema = v.InferOutput<typeof schema>;
const state = reactive({ const state = reactive({
token: "" token: "",
}) });
const toast = useToast() const toast = useToast();
async function onSubmit(event: FormSubmitEvent<Schema>) { async function onSubmit(event: FormSubmitEvent<Schema>) {
const token = event.data.token const token = event.data.token;
const res = await $fetch("https://door.svitan.dev/open", { const res = await $fetch("https://door.svitan.dev/open", {
method: "GET", method: "GET",
headers: { headers: {
Authorization: `Bearer ${token}` Authorization: `Bearer ${token}`,
} },
}) });
console.log(token) console.log(token);
console.log(res) console.log(res);
toast.add({ title: "Token saved", color: "success" }) toast.add({ title: "Token saved", color: "success" });
} }
onMounted(() => { onMounted(() => {
if (token.value) { if (token.value) {
return navigateTo("/") return navigateTo("/");
} }
}) });
</script> </script>

View File

@ -8,4 +8,4 @@ module.exports = {
extend: {}, extend: {},
}, },
plugins: [], plugins: [],
} };