🎨 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,7 +1,7 @@
<template>
<UApp>
<NuxtPage/>
</UApp>
<UApp>
<NuxtPage />
</UApp>
</template>
<style>

View File

@ -1,3 +1,3 @@
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
export default defineNuxtConfig({
compatibilityDate: '2025-05-15',
devtools: { enabled: true },
modules: ['@nuxt/icon', '@nuxt/ui', '@nuxtjs/tailwindcss']
})
compatibilityDate: "2025-05-15",
devtools: { enabled: true },
modules: ["@nuxt/icon", "@nuxt/ui", "@nuxtjs/tailwindcss"],
});

View File

@ -1,22 +1,22 @@
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@nuxt/icon": "1.13.0",
"@nuxt/ui": "3.1.3",
"@nuxtjs/tailwindcss": "7.0.0-beta.0",
"nuxt": "^3.17.5",
"typescript": "^5.6.3",
"valibot": "^1.1.0",
"vue": "^3.5.16",
"vue-router": "^4.5.1"
}
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@nuxt/icon": "1.13.0",
"@nuxt/ui": "3.1.3",
"@nuxtjs/tailwindcss": "7.0.0-beta.0",
"nuxt": "^3.17.5",
"typescript": "^5.6.3",
"valibot": "^1.1.0",
"vue": "^3.5.16",
"vue-router": "^4.5.1"
}
}

View File

@ -1,16 +1,24 @@
<template>
<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>
</main>
<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>
</main>
</template>
<script lang="ts" setup>
const token = useToken()
const token = useToken();
const locked = true;
onMounted(() => {
if (!token.value) {
return navigateTo("/token")
return navigateTo("/token");
}
console.log(token.value)
})
console.log(token.value);
});
</script>

View File

@ -1,50 +1,57 @@
<template>
<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>
<UInput v-model="state.token" placeholder="Your token..." size="xl"/>
<UInput
v-model="state.token"
placeholder="Your token..."
size="xl"
/>
</UFormField>
<UButton type="submit" size="xl">
Submit
</UButton>
<UButton type="submit" size="xl"> Submit </UButton>
</UForm>
</main>
</template>
<script lang="ts" setup>
import * as v from "valibot"
import type { FormSubmitEvent } from "@nuxt/ui"
import * as v from "valibot";
import type { FormSubmitEvent } from "@nuxt/ui";
const token = useToken()
const token = useToken();
const schema = v.object({
token: v.pipe(v.string(), v.nonEmpty("Please enter your token"))
})
type Schema = v.InferOutput<typeof schema>
token: v.pipe(v.string(), v.nonEmpty("Please enter your token")),
});
type Schema = v.InferOutput<typeof schema>;
const state = reactive({
token: ""
})
const toast = useToast()
token: "",
});
const toast = useToast();
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", {
method: "GET",
headers: {
Authorization: `Bearer ${token}`
}
})
Authorization: `Bearer ${token}`,
},
});
console.log(token)
console.log(res)
toast.add({ title: "Token saved", color: "success" })
console.log(token);
console.log(res);
toast.add({ title: "Token saved", color: "success" });
}
onMounted(() => {
if (token.value) {
return navigateTo("/")
return navigateTo("/");
}
})
});
</script>

View File

@ -1,11 +1,11 @@
module.exports = {
purge: [],
darkMode: "class", // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
purge: [],
darkMode: "class", // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
};

View File

@ -1,4 +1,4 @@
{
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
// https://nuxt.com/docs/guide/concepts/typescript
"extends": "./.nuxt/tsconfig.json"
}