feat: Create games and setup pages for later
This commit is contained in:
@@ -19,11 +19,71 @@
|
|||||||
</q-item-section>
|
</q-item-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
|
|
||||||
<q-item clickable v-ripple to="/user/username">
|
<q-expansion-item
|
||||||
<q-item-section>
|
label="User"
|
||||||
Set Username
|
icon="folder"
|
||||||
</q-item-section>
|
dense
|
||||||
</q-item>
|
expand-separator
|
||||||
|
switch-toggle-side
|
||||||
|
>
|
||||||
|
<q-list padding>
|
||||||
|
|
||||||
|
<q-item clickable v-ripple to="/user/username">
|
||||||
|
<q-item-section>
|
||||||
|
Set Username
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
<q-item clickable v-ripple to="/user/settings">
|
||||||
|
<q-item-section>
|
||||||
|
User Settings
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
</q-list>
|
||||||
|
|
||||||
|
</q-expansion-item>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<q-expansion-item
|
||||||
|
label="Game"
|
||||||
|
icon="folder"
|
||||||
|
dense
|
||||||
|
expand-separator
|
||||||
|
switch-toggle-side
|
||||||
|
>
|
||||||
|
<q-list padding>
|
||||||
|
|
||||||
|
<q-item clickable v-ripple to="/game/select">
|
||||||
|
<q-item-section>
|
||||||
|
Create Select Game Type
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
<q-item clickable v-ripple to="/game/local/create">
|
||||||
|
<q-item-section>
|
||||||
|
Create Local Game
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
<q-item clickable v-ripple to="/game/online/create">
|
||||||
|
<q-item-section>
|
||||||
|
Create Online Game
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
<q-item clickable v-ripple to="/game">
|
||||||
|
<q-item-section>
|
||||||
|
Game
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
|
||||||
|
</q-list>
|
||||||
|
|
||||||
|
</q-expansion-item>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
label="Tests"
|
label="Tests"
|
||||||
|
|||||||
7
frontend/src/pages/game/createLocalGamePage.vue
Normal file
7
frontend/src/pages/game/createLocalGamePage.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
CreateLocalGame
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
7
frontend/src/pages/game/createOnlineGamePage.vue
Normal file
7
frontend/src/pages/game/createOnlineGamePage.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
CreateOnlineGame
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
92
frontend/src/pages/game/gameModeSelectPage.vue
Normal file
92
frontend/src/pages/game/gameModeSelectPage.vue
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<template>
|
||||||
|
<div class="q-pa-lg flex flex-center" style="gap: 24px;">
|
||||||
|
<q-card
|
||||||
|
class="q-pa-lg shadow-3"
|
||||||
|
style="width: 400px; max-width: 90vw; border-radius: 16px;"
|
||||||
|
>
|
||||||
|
<q-card-section class="text-center">
|
||||||
|
<q-icon name="home" size="48px" color="primary" />
|
||||||
|
<div class="text-h6 q-mt-md">Local</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-actions align="center">
|
||||||
|
<q-btn
|
||||||
|
label="Go!"
|
||||||
|
color="primary"
|
||||||
|
@click="CreateGame(true)"
|
||||||
|
rounded
|
||||||
|
unelevated
|
||||||
|
size="lg"
|
||||||
|
class="full-width"
|
||||||
|
/>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
|
||||||
|
<q-card
|
||||||
|
class="q-pa-lg shadow-3"
|
||||||
|
style="width: 400px; max-width: 90vw; border-radius: 16px;"
|
||||||
|
>
|
||||||
|
<q-card-section class="text-center">
|
||||||
|
<q-icon name="public" size="48px" color="primary" />
|
||||||
|
<div class="text-h6 q-mt-md">Online</div>
|
||||||
|
</q-card-section>
|
||||||
|
|
||||||
|
<q-card-actions align="center">
|
||||||
|
<q-btn
|
||||||
|
label="Go!"
|
||||||
|
color="primary"
|
||||||
|
@click="CreateGame(false)"
|
||||||
|
rounded
|
||||||
|
unelevated
|
||||||
|
size="lg"
|
||||||
|
class="full-width"
|
||||||
|
/>
|
||||||
|
</q-card-actions>
|
||||||
|
</q-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
import { useQuasar, LocalStorage } from "quasar";
|
||||||
|
import { api } from 'src/boot/axios';
|
||||||
|
|
||||||
|
const $q = useQuasar();
|
||||||
|
const router = useRouter()
|
||||||
|
const user = ref({ username:"", id:0 });
|
||||||
|
|
||||||
|
const storedUser = LocalStorage.getItem("user")
|
||||||
|
if (storedUser) {
|
||||||
|
console.log(storedUser)
|
||||||
|
user.value = storedUser
|
||||||
|
} else {
|
||||||
|
router.push("/user/username")
|
||||||
|
}
|
||||||
|
|
||||||
|
async function CreateGame(is_local) {
|
||||||
|
console.log(user.value)
|
||||||
|
api.post("/api/games", {
|
||||||
|
user: user.value.id,
|
||||||
|
is_local: is_local
|
||||||
|
})
|
||||||
|
|
||||||
|
.then(function (response) {
|
||||||
|
console.log(response)
|
||||||
|
$q.notify({
|
||||||
|
type: "positive",
|
||||||
|
message: `Success!`,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
.catch(function (error) {
|
||||||
|
console.log(error);
|
||||||
|
|
||||||
|
$q.notify({
|
||||||
|
type: "negative",
|
||||||
|
message: error.response.data.error,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
7
frontend/src/pages/game/gamePage.vue
Normal file
7
frontend/src/pages/game/gamePage.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
Game
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
7
frontend/src/pages/user/userSettingsPage.vue
Normal file
7
frontend/src/pages/user/userSettingsPage.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<template>
|
||||||
|
Settings
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
//
|
||||||
|
</script>
|
||||||
@@ -41,9 +41,11 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar, LocalStorage } from "quasar";
|
||||||
import { api } from 'src/boot/axios';
|
import { api } from 'src/boot/axios';
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
|
|
||||||
|
const router = useRouter()
|
||||||
const $q = useQuasar();
|
const $q = useQuasar();
|
||||||
const user = ref({ username:"", id:0 });
|
const user = ref({ username:"", id:0 });
|
||||||
|
|
||||||
@@ -56,30 +58,33 @@ async function setUsername() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
api.post('/api/users', {
|
api.post("/api/users", {
|
||||||
username: user.value.username
|
username: user.value.username
|
||||||
})
|
})
|
||||||
|
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|
||||||
localStorage.setItem("username", response.data.username);
|
user.value.username = response.data.username
|
||||||
localStorage.setItem("id", response.data.id);
|
user.value.id = response.data.id
|
||||||
|
|
||||||
|
LocalStorage.setItem("user", user.value);
|
||||||
|
|
||||||
$q.notify({
|
$q.notify({
|
||||||
type: "positive",
|
type: "positive",
|
||||||
message: `Success!`,
|
message: "Success!",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.push("/game/select")
|
||||||
})
|
})
|
||||||
|
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|
||||||
$q.notify({
|
$q.notify({
|
||||||
type: "negative",
|
type: "negative",
|
||||||
message: error.response.data.error,
|
message: error.response.data.error,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,11 +4,17 @@ const routes = [
|
|||||||
component: () => import('layouts/MainLayout.vue'),
|
component: () => import('layouts/MainLayout.vue'),
|
||||||
children: [
|
children: [
|
||||||
{ path: '', component: () => import('pages/IndexPage.vue') },
|
{ path: '', component: () => import('pages/IndexPage.vue') },
|
||||||
{ path: 'test_DartPicker', component: () => import('src/pages/test/testDartPickerPage.vue') },
|
{ path: 'test_DartPicker', component: () => import('pages/test/testDartPickerPage.vue') },
|
||||||
{ path: 'test_NumbersPage', component: () => import('src/pages/test/testNumbersPage.vue') },
|
{ path: 'test_NumbersPage', component: () => import('pages/test/testNumbersPage.vue') },
|
||||||
{ path: 'test_WebSpeechApi', component: () => import('src/pages/test/testWebSpeechApi.vue') },
|
{ path: 'test_WebSpeechApi', component: () => import('pages/test/testWebSpeechApi.vue') },
|
||||||
|
|
||||||
{ path: 'user/username', component: () => import('src/pages/user/usernamePage.vue') },
|
{ path: 'user/username', component: () => import('pages/user/usernamePage.vue') },
|
||||||
|
{ path: '/user/settings', component: () => import('pages/user/userSettingsPage.vue') },
|
||||||
|
|
||||||
|
{ path: 'game', component: () => import('pages/game/gamePage.vue') },
|
||||||
|
{ path: 'game/select', component: () => import('pages/game/gameModeSelectPage.vue') },
|
||||||
|
{ path: 'game/local/create', component: () => import('pages/game/createLocalGamePage.vue') },
|
||||||
|
{ path: 'game/online/create', component: () => import('pages/game/createOnlineGamePage.vue') },
|
||||||
|
|
||||||
{ path: 'error', component: () => import('pages/ErrorPage.vue') }
|
{ path: 'error', component: () => import('pages/ErrorPage.vue') }
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user