feat: username input and small fixes

This commit is contained in:
2025-09-12 14:14:28 +02:00
parent 923c17840d
commit 615701c8f3
6 changed files with 105 additions and 3 deletions

View File

@@ -93,7 +93,7 @@ export default defineConfig((/* ctx */) => {
// directives: [],
// Quasar plugins
plugins: [],
plugins: ["Notify"],
},
// animations: 'all', // --- includes all animations

View File

@@ -0,0 +1,13 @@
import { boot } from 'quasar/wrappers';
import axios from 'axios';
const api = axios.create({
baseURL: "https://localhost:5555"
});
export default boot(({ app }) => {
app.config.globalProperties.$axios = axios;
app.config.globalProperties.$api = api;
});
export { api };

View File

@@ -1,11 +1,11 @@
import axios from "axios";
import { api } from 'src/boot/axios';
export default async () => {
try {
const response = await axios.get("https://localhost:5555/api/healthcheck");
const response = await api.get("/api/healthcheck");
if (!response.data || response.data.status !== "ok") {
console.log("a")

View File

@@ -19,6 +19,12 @@
</q-item-section>
</q-item>
<q-item clickable v-ripple to="/user/username">
<q-item-section>
Set Username
</q-item-section>
</q-item>
<q-expansion-item
label="Tests"
icon="folder"

View File

@@ -0,0 +1,81 @@
<template>
<div class="q-pa-md flex flex-center">
<q-card
class="q-pa-lg shadow-3"
style="width: 400px; max-width: 90vw; border-radius: 16px;"
>
<q-card-section class="text-center">
<div class="text-h6 q-mt-md">Enter Username</div>
</q-card-section>
<q-card-section>
<q-input
v-model="user.username"
filled
label="Username"
maxlength="32"
counter
dense
style="border-radius: 6px;"
>
<template #prepend>
<q-icon name="account_circle" />
</template>
</q-input>
</q-card-section>
<q-card-actions align="center">
<q-btn
label="Go!"
color="primary"
@click="setUsername"
rounded
unelevated
size="lg"
class="full-width"
/>
</q-card-actions>
</q-card>
</div>
</template>
<script setup>
import { ref } from "vue";
import { useQuasar } from "quasar";
import { api } from 'src/boot/axios';
const $q = useQuasar();
const user = ref({ username:"", id:0 });
async function setUsername() {
if (!user.value.username) {
$q.notify({
type: "negative",
message: "Please enter a username!",
});
return;
}
api.post('/api/users', {
username: user.value.username+"aaaaaa"
})
.then(function (response) {
console.log(response);
localStorage.setItem("username", user.value.username);
localStorage.setItem("id", user.value.id);
$q.notify({
type: "positive",
message: `Success!`,
});
})
.catch(function (error) {
console.log(error);
window.location.href = '/#/error?msg=API%20unreachable';
});
}
</script>

View File

@@ -8,6 +8,8 @@ const routes = [
{ path: 'test_NumbersPage', component: () => import('src/pages/test/testNumbersPage.vue') },
{ path: 'test_WebSpeechApi', component: () => import('src/pages/test/testWebSpeechApi.vue') },
{ path: 'user/username', component: () => import('src/pages/user/usernamePage.vue') },
{ path: 'error', component: () => import('pages/ErrorPage.vue') }
],
},