🎨 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> <template>
<UApp> <UApp>
<NuxtPage/> <NuxtPage />
</UApp> </UApp>
</template> </template>
<style> <style>

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

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
</main> icon="material-symbols:lock"
size="xl"
color="primary"
variant="solid"
>
Lock
</UButton>
</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

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

View File

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