Compare commits
2 Commits
0.25.0
...
dbffce8818
| Author | SHA1 | Date | |
|---|---|---|---|
| dbffce8818 | |||
|
|
f29ed9d338 |
16
CHANGELOG.md
16
CHANGELOG.md
@@ -160,19 +160,3 @@
|
|||||||
### Features
|
### Features
|
||||||
|
|
||||||
* Update LobbyComponent to use icons for player removal buttons ([c653746](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/c6537467f87d60aeece18f86f42c839d5437c18b))
|
* Update LobbyComponent to use icons for player removal buttons ([c653746](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/c6537467f87d60aeece18f86f42c839d5437c18b))
|
||||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.22.0...0.0.0) (2026-01-13)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **ui:** Tie selection ([#26](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/26)) ([6c914b1](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/6c914b1421030897d47449087dd1694068e84436))
|
|
||||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.23.0...0.0.0) (2026-01-20)
|
|
||||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.23.1...0.0.0) (2026-01-20)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* Update docker-entrypoint.sh and vite.config.ts for improved runtime handling and API navigation ([cd950e9](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/cd950e952117cebe0ec46a18fc5b2cf90b247766))
|
|
||||||
## [0.0.0](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/compare/0.24.0...0.0.0) (2026-01-22)
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **ui:** FRO-26: Tie Component ([#30](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/issues/30)) ([9823af2](https://git.janis-eccarius.de/KnockOutWhist/KnockOutWhist-Frontend/commit/9823af2a1cee6cc4063f6f55a8ab64ec63525e84))
|
|
||||||
|
|||||||
@@ -15,5 +15,6 @@ else
|
|||||||
echo "No runtime template found at $TEMPLATE_PATH, skipping"
|
echo "No runtime template found at $TEMPLATE_PATH, skipping"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Start nginx in foreground
|
||||||
exec nginx -g 'daemon off;'
|
exec nginx -g 'daemon off;'
|
||||||
|
|
||||||
|
|||||||
73
src/App.vue
73
src/App.vue
@@ -3,7 +3,10 @@ import { RouterView } from 'vue-router'
|
|||||||
import { onMounted, onUnmounted, watch } from 'vue';
|
import { onMounted, onUnmounted, watch } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { useUserInfo } from "@/composables/useUserInfo";
|
import { useUserInfo } from "@/composables/useUserInfo";
|
||||||
import {Dark } from "quasar";
|
import { useIngame } from "@/composables/useIngame";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
import { useWebSocket } from "@/composables/useWebsocket";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -19,26 +22,15 @@ const handleOnlineStatusChange = () => {
|
|||||||
|
|
||||||
let interval: number | null = null;
|
let interval: number | null = null;
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(() => {
|
||||||
window.addEventListener('online', handleOnlineStatusChange);
|
window.addEventListener('online', handleOnlineStatusChange);
|
||||||
|
|
||||||
// Initialize dark mode based on browser preference
|
|
||||||
Dark.set('auto');
|
|
||||||
|
|
||||||
// Immediately check user state on app load
|
|
||||||
if (navigator.onLine) {
|
|
||||||
await info.requestState();
|
|
||||||
if (!info.username && route.meta.requiresAuth) {
|
|
||||||
router.push({ name: '/' });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continuously check user state every 10 seconds
|
// Continuously check user state every 10 seconds
|
||||||
interval = window.setInterval(async () => {
|
interval = window.setInterval(async () => {
|
||||||
if (navigator.onLine) {
|
if (navigator.onLine && route.name !== 'login' && route.name !== 'offline') {
|
||||||
await info.requestState();
|
await info.requestState();
|
||||||
if (!info.username && route.meta.requiresAuth) {
|
if (!info.username && route.name !== 'login') {
|
||||||
router.push({ name: '/' });
|
router.push({ name: 'login' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 10000);
|
}, 10000);
|
||||||
@@ -56,6 +48,55 @@ watch(() => info.gameId, (newGameId) => {
|
|||||||
router.push({ name: 'game' });
|
router.push({ name: 'game' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const ig = useIngame()
|
||||||
|
const { isWsConnected } = storeToRefs(ig)
|
||||||
|
const wb = useWebSocket()
|
||||||
|
const $q = useQuasar();
|
||||||
|
|
||||||
|
watch(isWsConnected, (connected) => {
|
||||||
|
if (!connected && info.gameId && route.name === 'game') {
|
||||||
|
showReconnectDialog();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function showReconnectDialog() {
|
||||||
|
$q.dialog({
|
||||||
|
title: 'Connection Lost',
|
||||||
|
message: 'The connection to the game server was lost. Would you like to reconnect?',
|
||||||
|
persistent: true,
|
||||||
|
ok: {
|
||||||
|
label: 'Reconnect',
|
||||||
|
color: 'positive'
|
||||||
|
},
|
||||||
|
cancel: {
|
||||||
|
label: 'Quit',
|
||||||
|
color: 'negative'
|
||||||
|
}
|
||||||
|
}).onOk(() => {
|
||||||
|
reconnect();
|
||||||
|
}).onCancel(() => {
|
||||||
|
router.replace("/");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reconnect() {
|
||||||
|
try {
|
||||||
|
await wb.connect();
|
||||||
|
$q.notify({
|
||||||
|
message: 'Reconnected successfully!',
|
||||||
|
color: 'positive',
|
||||||
|
icon: 'check'
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
$q.notify({
|
||||||
|
message: 'Failed to reconnect. Please try again.',
|
||||||
|
color: 'negative',
|
||||||
|
icon: 'error'
|
||||||
|
});
|
||||||
|
showReconnectDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,68 +1,40 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useUserInfo } from '@/composables/useUserInfo';
|
|
||||||
import { useQuasar } from 'quasar';
|
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userInfo = useUserInfo();
|
|
||||||
const $q = useQuasar();
|
|
||||||
|
|
||||||
const menuItems = [
|
const menuItems = [
|
||||||
{
|
{
|
||||||
title: 'Create game',
|
title: 'Create game',
|
||||||
description: 'Create a new game and invite your friends to play with you.',
|
description: 'Create a new game and invite your friends to play with you.',
|
||||||
icon: 'add_circle_outline',
|
icon: 'add_circle_outline',
|
||||||
routeName: 'create-Game',
|
routeName: 'create-Game',
|
||||||
color: 'green-9',
|
color: 'green-9'
|
||||||
requiresAuth: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Spiel beitreten',
|
title: 'Spiel beitreten',
|
||||||
description: 'Join a game by typing in the game identifier.',
|
description: 'Join a game by typing in the game identifier.',
|
||||||
icon: 'login',
|
icon: 'login',
|
||||||
routeName: 'join-Game',
|
routeName: 'join-Game',
|
||||||
color: 'blue-9',
|
color: 'blue-9'
|
||||||
requiresAuth: true
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Settings',
|
title: 'Settings',
|
||||||
description: 'This area is currently under construction.',
|
description: 'This area is currently under construction.',
|
||||||
icon: 'settings',
|
icon: 'settings',
|
||||||
routeName: 'settings',
|
routeName: 'settings',
|
||||||
color: 'grey-8',
|
color: 'grey-8'
|
||||||
requiresAuth: false
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Rules',
|
title: 'Rules',
|
||||||
description: 'Look at the rules to have a clear understanding for playing the game.',
|
description: 'Look at the rules to have a clear understanding for playing the game.',
|
||||||
icon: 'settings',
|
icon: 'settings',
|
||||||
routeName: 'rule-Game',
|
routeName: 'rules-Game',
|
||||||
color: 'grey-8',
|
color: 'grey-8'
|
||||||
requiresAuth: false
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const navigateTo = (item: any) => {
|
const navigateTo = (routeName: string) => {
|
||||||
if (item.requiresAuth && !userInfo.username) {
|
router.push({ name: routeName });
|
||||||
$q.dialog({
|
|
||||||
title: 'Authentication Required',
|
|
||||||
message: 'You need to be logged in to create or join a game. Would you like to log in or sign up?',
|
|
||||||
ok: {
|
|
||||||
label: 'Login',
|
|
||||||
color: 'primary'
|
|
||||||
},
|
|
||||||
cancel: {
|
|
||||||
label: 'Sign Up',
|
|
||||||
color: 'secondary'
|
|
||||||
}
|
|
||||||
}).onOk(() => {
|
|
||||||
router.push({ name: 'login' });
|
|
||||||
}).onCancel(() => {
|
|
||||||
router.push({ name: 'register' });
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
router.push({ name: item.routeName });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -85,7 +57,7 @@ const navigateTo = (item: any) => {
|
|||||||
<q-card
|
<q-card
|
||||||
class="menu-card bg-dark text-white q-pa-sm cursor-pointer"
|
class="menu-card bg-dark text-white q-pa-sm cursor-pointer"
|
||||||
v-ripple
|
v-ripple
|
||||||
@click="navigateTo(item)"
|
@click="navigateTo(item.routeName)"
|
||||||
>
|
>
|
||||||
<q-card-section class="row items-center no-wrap">
|
<q-card-section class="row items-center no-wrap">
|
||||||
<q-avatar
|
<q-avatar
|
||||||
|
|||||||
@@ -68,21 +68,8 @@ const handleLogoff = () => {
|
|||||||
</q-menu>
|
</q-menu>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-else class="row items-center q-gutter-x-sm">
|
<div v-else class="text-caption text-grey-4">
|
||||||
<q-btn
|
Not Logged In
|
||||||
flat
|
|
||||||
color="white"
|
|
||||||
label="Login"
|
|
||||||
@click="router.push({ name: 'login' })"
|
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
outline
|
|
||||||
color="white"
|
|
||||||
label="Sign Up"
|
|
||||||
@click="router.push({ name: 'register' })"
|
|
||||||
size="sm"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {useWebSocket} from "@/composables/useWebsocket.ts";
|
import {useWebSocket} from "@/composables/useWebsocket.ts";
|
||||||
import {useIngame} from "@/composables/useIngame.ts";
|
import {useIngame} from "@/composables/useIngame.ts";
|
||||||
import type {GameInfo, LobbyInfo, TieInfo, TrumpInfo} from "@/types/GameTypes.ts";
|
import type { TieInfo } from "@/types/GameTypes.ts";
|
||||||
import {useQuasar} from "quasar";
|
import {useQuasar} from "quasar";
|
||||||
import { ref } from 'vue';
|
import { computed, nextTick, ref } from 'vue'
|
||||||
import { computed, nextTick } from 'vue'
|
|
||||||
|
|
||||||
const wb = useWebSocket()
|
const wb = useWebSocket()
|
||||||
const wi = useIngame()
|
const wi = useIngame()
|
||||||
@@ -21,60 +20,65 @@ function getPlayerName(playerId: string) {
|
|||||||
return tieInf.value.tiedPlayers.find(p => p.id === playerId)?.name || 'Player';
|
return tieInf.value.tiedPlayers.find(p => p.id === playerId)?.name || 'Player';
|
||||||
}
|
}
|
||||||
const myRevealedCard = computed(() => {
|
const myRevealedCard = computed(() => {
|
||||||
|
// 1. Get your own ID from the 'self' object in the DTO
|
||||||
const myId = tieInf.value.self?.id;
|
const myId = tieInf.value.self?.id;
|
||||||
|
|
||||||
|
// 2. Safety check: ensure we have an ID and the map exists
|
||||||
if (!myId || !tieInf.value.selectedCards) return null;
|
if (!myId || !tieInf.value.selectedCards) return null;
|
||||||
|
|
||||||
|
// 3. Look up the CardDTO using your ID as the key
|
||||||
const card = tieInf.value.selectedCards[myId];
|
const card = tieInf.value.selectedCards[myId];
|
||||||
|
|
||||||
|
// 4. If found, convert the relative path to a full URL
|
||||||
return card ? getCardImagePath(card.path) : null;
|
return card ? getCardImagePath(card.path) : null;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isFlipping = ref(false);
|
const isFlipping = ref(false);
|
||||||
const showPickScreen = computed(() => {
|
// Used to force-remount the flipping subtree so the CSS transition/animation restarts reliably
|
||||||
const isMyTurn = tieInf.value.self?.id === tieInf.value.currentPlayer?.id;
|
const revealKey = ref(0);
|
||||||
return isFlipping.value || (isMyTurn && !showResultScreen.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
const showResultScreen = computed(() => {
|
// This replaces your v-if check.
|
||||||
const allPicked = Object.keys(tieInf.value.selectedCards).length === tieInf.value.tiedPlayers.length;
|
// It keeps the "Pick" screen visible while flipping.
|
||||||
return allPicked && !isFlipping.value;
|
const showPickScreen = computed(() => {
|
||||||
});
|
const isMyTurn = tieInf.value.self?.id === tieInf.value.currentPlayer?.id;
|
||||||
|
return isMyTurn || isFlipping.value;
|
||||||
|
});
|
||||||
|
|
||||||
|
function selectTie(tieIndex: number) {
|
||||||
|
// Use model.value because it's a ref
|
||||||
|
wb.sendAndWait("PickTie", { cardIndex: tieIndex })
|
||||||
|
.then(async () => {
|
||||||
|
console.log("Server accepted pick, starting animation...");
|
||||||
|
|
||||||
function selectTie(tieIndex: number) {
|
// 1. Trigger the animation state
|
||||||
isFlipping.value = true;
|
isFlipping.value = true;
|
||||||
nextTick(() => {
|
// 2. Force a remount of the flip-card for the selected card so the flip restarts even if src doesn't change
|
||||||
wb.sendAndWait("PickTie", { cardIndex: tieIndex })
|
revealKey.value += 1;
|
||||||
.then(() => {
|
await nextTick();
|
||||||
console.log("Server accepted pick, starting animation...");
|
|
||||||
console.log("CARD SELECTED: " + Object.keys(tieInf.value.selectedCards).length)
|
|
||||||
|
|
||||||
|
// 3. Optional Notification
|
||||||
|
$q.notify({
|
||||||
|
message: "Card revealed!",
|
||||||
|
color: "positive",
|
||||||
|
position: "top",
|
||||||
|
timeout: 1000
|
||||||
|
});
|
||||||
|
|
||||||
$q.notify({
|
// 4. Wait for animation to finish before switching to Waiting Screen
|
||||||
message: "Card revealed!",
|
setTimeout(() => {
|
||||||
color: "positive",
|
isFlipping.value = false;
|
||||||
position: "top",
|
model.value = null;
|
||||||
timeout: 1000
|
}, 500);
|
||||||
});
|
})
|
||||||
|
.catch((error) => {
|
||||||
setTimeout(() => {
|
console.error("Pick failed:", error);
|
||||||
isFlipping.value = false;
|
$q.notify({
|
||||||
model.value = null;
|
message: error.message || "Failed to pick card",
|
||||||
}, 2500);
|
color: "negative",
|
||||||
})
|
position: "top"
|
||||||
.catch((error) => {
|
});
|
||||||
isFlipping.value = false;
|
});
|
||||||
console.error("Pick failed:", error);
|
}
|
||||||
$q.notify({
|
|
||||||
message: error.message || "Failed to pick card",
|
|
||||||
color: "negative",
|
|
||||||
position: "top"
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
const model = ref<number | null>(null)
|
const model = ref<number | null>(null)
|
||||||
const options = computed(() => {
|
const options = computed(() => {
|
||||||
const list = []
|
const list = []
|
||||||
@@ -114,18 +118,41 @@ const options = computed(() => {
|
|||||||
:class="{ 'selected-card': model === n, 'is-flipping': isFlipping && model === n }"
|
:class="{ 'selected-card': model === n, 'is-flipping': isFlipping && model === n }"
|
||||||
>
|
>
|
||||||
<div class="card-inner">
|
<div class="card-inner">
|
||||||
<q-img
|
<!-- Flip card: keep both faces mounted; flip the inner wrapper. -->
|
||||||
:src="(model === n && myRevealedCard) ? myRevealedCard : getCardImagePath(tieBlankCard)"
|
<div
|
||||||
class="card-image shadow-24"
|
class="flip-card"
|
||||||
:class="{ 'animate-reveal': isFlipping && model === n }"
|
:class="{ 'flip-card--flipped': isFlipping && model === n && !!myRevealedCard }"
|
||||||
/>
|
:key="(isFlipping && model === n) ? `${revealKey}-${n}` : `static-${n}`"
|
||||||
|
>
|
||||||
|
<div class="flip-card__inner">
|
||||||
|
<!-- FRONT: blank card (deck back) -->
|
||||||
|
<div class="flip-card__face flip-card__front">
|
||||||
|
<q-img
|
||||||
|
:src="getCardImagePath(tieBlankCard)"
|
||||||
|
class="card-image shadow-24"
|
||||||
|
no-spinner
|
||||||
|
no-transition
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-if="!isFlipping" class="card-number">
|
<!-- BACK: revealed card (your pick result) -->
|
||||||
{{ n }}
|
<div class="flip-card__face flip-card__back">
|
||||||
|
<q-img
|
||||||
|
:src="(model === n && myRevealedCard) ? myRevealedCard : getCardImagePath(tieBlankCard)"
|
||||||
|
class="card-image shadow-24"
|
||||||
|
no-spinner
|
||||||
|
no-transition
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
<div v-if="!isFlipping" class="card-number">
|
||||||
</div>
|
{{ n }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="action-area" :class="{ 'visible': model !== null && !isFlipping }">
|
<div class="action-area" :class="{ 'visible': model !== null && !isFlipping }">
|
||||||
<div class="row q-gutter-md justify-center items-center">
|
<div class="row q-gutter-md justify-center items-center">
|
||||||
@@ -146,7 +173,7 @@ const options = computed(() => {
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<q-card v-else-if="!showResultScreen" class="game-container text-center overflow-hidden">
|
<q-card v-else class="game-container text-center overflow-hidden">
|
||||||
<q-card-section class="content-layer q-py-xl">
|
<q-card-section class="content-layer q-py-xl">
|
||||||
<div class="text-overline text-primary letter-spacing-2">Tie-Break Round</div>
|
<div class="text-overline text-primary letter-spacing-2">Tie-Break Round</div>
|
||||||
|
|
||||||
@@ -173,7 +200,7 @@ const options = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="q-mt-xl">
|
<div class="q-mt-xl">
|
||||||
<q-spinner-hourglass color="white" size="4em" />
|
<q-spinner-hourglass color="primary" size="4em" />
|
||||||
<div class="text-subtitle1 text-grey-5 q-mt-sm italic">
|
<div class="text-subtitle1 text-grey-5 q-mt-sm italic">
|
||||||
Waiting for <span class="text-white">{{ tieInf.currentPlayer?.name }}</span> to pick a card...
|
Waiting for <span class="text-white">{{ tieInf.currentPlayer?.name }}</span> to pick a card...
|
||||||
</div>
|
</div>
|
||||||
@@ -182,61 +209,6 @@ const options = computed(() => {
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
</q-card>
|
</q-card>
|
||||||
<q-card v-else class="game-container tie-break-card text-center overflow-hidden">
|
|
||||||
<div class="absolute-full bg-gradient-dark opacity-80"></div>
|
|
||||||
|
|
||||||
<q-card-section class="content-layer q-py-xl">
|
|
||||||
<div class="column items-center q-mb-xl">
|
|
||||||
<q-icon
|
|
||||||
:name="(tieInf.winners?.length || 0) > 1 ? 'auto_renew' : 'workspace_premium'"
|
|
||||||
:color="(tieInf.winners?.length || 0) > 1 ? 'info' : 'warning'"
|
|
||||||
size="64px"
|
|
||||||
class="q-mb-sm"
|
|
||||||
/>
|
|
||||||
<div class="text-h3 text-weight-bolder text-white text-uppercase tracking-widest">
|
|
||||||
{{ (tieInf.winners?.length || 0) > 1 ? 'Another Tie!' : 'Tie Broken' }}
|
|
||||||
</div>
|
|
||||||
<p class="text-subtitle1 text-grey-4">
|
|
||||||
{{ (tieInf.winners?.length || 0) > 1 ? 'The high cards matched. Draw again!' : 'We have a winner.' }}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row justify-center items-end q-gutter-lg">
|
|
||||||
<div
|
|
||||||
v-for="(card, playerId) in tieInf.selectedCards"
|
|
||||||
:key="playerId"
|
|
||||||
class="revealed-card-wrapper"
|
|
||||||
:class="{
|
|
||||||
'winner-glow': tieInf.winners?.map(player => player.id).includes(playerId),
|
|
||||||
'opacity-40': !tieInf.winners?.map(player => player.id).includes(playerId) && (tieInf.winners?.length || 0) > 0
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div class="player-tag q-mb-md">
|
|
||||||
<div class="text-overline text-white">{{ getPlayerName(playerId) }}</div>
|
|
||||||
<q-badge
|
|
||||||
v-if="tieInf.winners?.map(player => player.id).includes(playerId)"
|
|
||||||
:color="tieInf.winners.length > 1 ? 'info' : 'positive'"
|
|
||||||
:label="tieInf.winners.length > 1 ? 'Still Tied' : 'Winner'"
|
|
||||||
rounded
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="card-stack">
|
|
||||||
<q-img
|
|
||||||
:src="getCardImagePath(card.path)"
|
|
||||||
class="card-image-reveal shadow-24"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column items-center q-mt-lg">
|
|
||||||
<q-spinner-hourglass color="white" size="4em" />
|
|
||||||
<div class="text-subtitle1 text-white q-mt-sm italic">
|
|
||||||
Preparing trumpsuit selection...
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</q-card-section>
|
|
||||||
</q-card>
|
|
||||||
</transition>
|
</transition>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -412,38 +384,55 @@ const options = computed(() => {
|
|||||||
}
|
}
|
||||||
.card-inner {
|
.card-inner {
|
||||||
perspective: 1000px;
|
perspective: 1000px;
|
||||||
|
transform-style: preserve-3d;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The Reveal Animation */
|
/* --- Flip card (reliable 3D flip) --- */
|
||||||
.animate-reveal {
|
.flip-card {
|
||||||
animation: dramaticFlip 1.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
|
width: 60px;
|
||||||
|
/* height follows image; q-img sets its own box, but we want a stable 3D container */
|
||||||
|
perspective: 1000px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card__inner {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
transform-style: preserve-3d;
|
||||||
|
transition: transform 1.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card__face {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
backface-visibility: hidden;
|
backface-visibility: hidden;
|
||||||
z-index: 1000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes dramaticFlip {
|
/* Ensure the q-img root stretches to fill the face */
|
||||||
0% {
|
.flip-card__face :deep(.q-img) {
|
||||||
transform: rotateY(0deg) scale(1);
|
width: 100%;
|
||||||
}
|
|
||||||
40% {
|
|
||||||
/* Halfway: Card is vertical and lifted up */
|
|
||||||
transform: rotateY(90deg) scale(1.5) translateY(-30px);
|
|
||||||
filter: brightness(1.3);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
/* Final: Card is flat again, showing the face */
|
|
||||||
transform: rotateY(0deg) scale(1.3) translateY(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ensure the image isn't mirrored after the rotation logic */
|
.flip-card__front {
|
||||||
.animate-reveal :deep(img) {
|
transform: rotateY(0deg);
|
||||||
backface-visibility: hidden;
|
}
|
||||||
|
|
||||||
|
.flip-card__back {
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card--flipped .flip-card__inner {
|
||||||
|
/* Lift/scale a bit like your original dramatic flip */
|
||||||
|
transform: rotateY(180deg) scale(1.3) translateY(-10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* While flipping, don't let hover/selected transforms fight the 3D transform */
|
||||||
|
.tie-card-wrapper.is-flipping:hover {
|
||||||
|
transform: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Optional: Slight pulse while the button is waiting to be clicked */
|
/* Optional: Slight pulse while the button is waiting to be clicked */
|
||||||
.selected-card:not(.is-flipping) {
|
.selected-card:not(.is-flipping) {
|
||||||
animation: pulse 2s infinite;
|
animation: pulse 0.5s infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse {
|
@keyframes pulse {
|
||||||
@@ -451,35 +440,4 @@ const options = computed(() => {
|
|||||||
50% { transform: scale(1.45); box-shadow: 0 0 40px rgba(25, 118, 210, 0.6); }
|
50% { transform: scale(1.45); box-shadow: 0 0 40px rgba(25, 118, 210, 0.6); }
|
||||||
100% { transform: scale(1.4); }
|
100% { transform: scale(1.4); }
|
||||||
}
|
}
|
||||||
/* Add to previous styles */
|
|
||||||
|
|
||||||
.winner-glow .card-image {
|
|
||||||
border-color: #31ccec; /* Default 'info' blue for ongoing ties */
|
|
||||||
transform: scale(1.05) translateY(-10px);
|
|
||||||
box-shadow: 0 10px 40px rgba(49, 204, 236, 0.4) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If there is only one winner, change glow to Gold */
|
|
||||||
.winner-glow:only-child .card-image,
|
|
||||||
.tie-break-card .winner-glow:has(.bg-positive) .card-image {
|
|
||||||
border-color: #f2c037;
|
|
||||||
box-shadow: 0 10px 40px rgba(242, 192, 55, 0.5) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.opacity-40 {
|
|
||||||
opacity: 0.4;
|
|
||||||
filter: grayscale(0.8);
|
|
||||||
transform: scale(0.9);
|
|
||||||
transition: all 0.5s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-stack {
|
|
||||||
perspective: 1000px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-image-reveal {
|
|
||||||
width: 130px;
|
|
||||||
border-radius: 10px;
|
|
||||||
transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ref, onMounted, onBeforeUnmount, watch } from "vue";
|
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||||
import {
|
import {
|
||||||
connectWebSocket,
|
connectWebSocket,
|
||||||
disconnectWebSocket,
|
disconnectWebSocket,
|
||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
isWebSocketConnected,
|
isWebSocketConnected,
|
||||||
setDefaultHandler,
|
setDefaultHandler,
|
||||||
} from "@/services/ws";
|
} from "@/services/ws";
|
||||||
import { useIngame } from "@/composables/useIngame";
|
|
||||||
|
|
||||||
function defaultEventHandler<T = any>(data: (data: T) => void) {
|
function defaultEventHandler<T = any>(data: (data: T) => void) {
|
||||||
setDefaultHandler(data);
|
setDefaultHandler(data);
|
||||||
@@ -17,28 +16,15 @@ function defaultEventHandler<T = any>(data: (data: T) => void) {
|
|||||||
export function useWebSocket() {
|
export function useWebSocket() {
|
||||||
const isConnected = ref(isWebSocketConnected());
|
const isConnected = ref(isWebSocketConnected());
|
||||||
const lastMessage = ref<any>(null);
|
const lastMessage = ref<any>(null);
|
||||||
|
|
||||||
const lastError = ref<string | null>(null);
|
const lastError = ref<string | null>(null);
|
||||||
|
|
||||||
// Get ingame store to sync connection state
|
|
||||||
const ig = useIngame();
|
|
||||||
|
|
||||||
// Watch the ingame store's connection state and keep this composable in sync
|
|
||||||
watch(() => ig.isWsConnected, (connected) => {
|
|
||||||
isConnected.value = connected;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Also update this composable's state when connecting/disconnecting
|
|
||||||
const updateConnectionState = (connected: boolean) => {
|
|
||||||
isConnected.value = connected;
|
|
||||||
};
|
|
||||||
|
|
||||||
async function safeConnect(url?: string) {
|
async function safeConnect(url?: string) {
|
||||||
return connectWebSocket(url)
|
return connectWebSocket(url)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
updateConnectionState(true);
|
isConnected.value = true;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
updateConnectionState(false);
|
|
||||||
lastError.value = err?.message ?? "Unknown WS error";
|
lastError.value = err?.message ?? "Unknown WS error";
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|||||||
10
src/main.ts
10
src/main.ts
@@ -5,9 +5,8 @@ import App from './App.vue'
|
|||||||
import router from './router'
|
import router from './router'
|
||||||
import Particles from "@tsparticles/vue3";
|
import Particles from "@tsparticles/vue3";
|
||||||
import { loadFull } from "tsparticles";
|
import { loadFull } from "tsparticles";
|
||||||
import {Quasar, Notify, QExpansionItem, Dialog, Dark} from 'quasar'
|
import { Quasar, Notify, QExpansionItem } from 'quasar'
|
||||||
import '@quasar/extras/material-icons/material-icons.css'
|
import '@quasar/extras/material-icons/material-icons.css'
|
||||||
import '@quasar/extras/bootstrap-icons/bootstrap-icons.css'
|
|
||||||
import 'quasar/dist/quasar.css'
|
import 'quasar/dist/quasar.css'
|
||||||
import { createPinia } from 'pinia'
|
import { createPinia } from 'pinia'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
@@ -26,9 +25,10 @@ initWebSocket(ui);
|
|||||||
app.use(router)
|
app.use(router)
|
||||||
app.use(Quasar, {
|
app.use(Quasar, {
|
||||||
plugins: {
|
plugins: {
|
||||||
Notify,
|
Notify
|
||||||
Dialog,
|
},
|
||||||
Dark
|
components: {
|
||||||
|
QExpansionItem
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
app.use(VueAxios, axios)
|
app.use(VueAxios, axios)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import LoginView from '../views/LoginView.vue'
|
import LoginView from '../views/LoginView.vue'
|
||||||
import RegisterView from '../views/RegisterView.vue'
|
|
||||||
import UsernameSelectionView from '../views/UsernameSelectionView.vue'
|
|
||||||
import MainMenuView from '../views/MainMenuView.vue'
|
import MainMenuView from '../views/MainMenuView.vue'
|
||||||
import createGameView from '../views/CreateGame.vue'
|
import createGameView from '../views/CreateGame.vue'
|
||||||
import joinGameView from "@/views/JoinGameView.vue";
|
import joinGameView from "@/views/JoinGameView.vue";
|
||||||
@@ -19,13 +17,13 @@ const router = createRouter({
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
component: MainMenuView,
|
component: MainMenuView,
|
||||||
meta: { requiresAuth: false },
|
meta: { requiresAuth: true },
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
name: 'mainmenu',
|
name: 'mainmenu',
|
||||||
component: defaultMenu,
|
component: defaultMenu,
|
||||||
meta: { requiresAuth: false }
|
meta: { requiresAuth: true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'create',
|
path: 'create',
|
||||||
@@ -43,7 +41,7 @@ const router = createRouter({
|
|||||||
path: 'rules',
|
path: 'rules',
|
||||||
name: 'rules-Game',
|
name: 'rules-Game',
|
||||||
component: rulesView,
|
component: rulesView,
|
||||||
meta: {requiresAuth: false }
|
meta: {requiresAuth: true }
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -53,18 +51,6 @@ const router = createRouter({
|
|||||||
component: LoginView,
|
component: LoginView,
|
||||||
meta: { requiresAuth: false }
|
meta: { requiresAuth: false }
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: '/register',
|
|
||||||
name: 'register',
|
|
||||||
component: RegisterView,
|
|
||||||
meta: { requiresAuth: false }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/select-username',
|
|
||||||
name: 'select-username',
|
|
||||||
component: UsernameSelectionView,
|
|
||||||
meta: { requiresAuth: false }
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: '/game',
|
path: '/game',
|
||||||
name: 'game',
|
name: 'game',
|
||||||
@@ -83,16 +69,19 @@ const router = createRouter({
|
|||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
const info = useUserInfo();
|
const info = useUserInfo();
|
||||||
const isOnline = navigator.onLine;
|
const isOnline = navigator.onLine;
|
||||||
|
|
||||||
if (to.name === 'offline') {
|
if (to.name === 'offline') {
|
||||||
if (isOnline) {
|
if (isOnline) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await info.requestState();
|
await info.requestState();
|
||||||
|
|
||||||
if (!info.username) {
|
if (!info.username) {
|
||||||
info.clearUserInfo();
|
info.clearUserInfo();
|
||||||
return next('/login');
|
return next('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
return next({ name: 'mainmenu' });
|
return next({ name: 'mainmenu' });
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
info.clearUserInfo();
|
info.clearUserInfo();
|
||||||
return next('/login');
|
return next('/login');
|
||||||
@@ -101,27 +90,28 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isOnline) {
|
if (!isOnline) {
|
||||||
return next({ name: 'offline' });
|
return next({ name: 'offline' });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!to.meta.requiresAuth) return next();
|
if (!to.meta.requiresAuth) return next();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await info.requestState();
|
await info.requestState();
|
||||||
|
|
||||||
if (!info.username) {
|
if (!info.username) {
|
||||||
info.clearUserInfo();
|
info.clearUserInfo();
|
||||||
return next('/login');
|
return next('/login');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.gameId && to.name !== 'game') {
|
if (info.gameId && to.name !== 'game') {
|
||||||
return next({ name: 'game' });
|
return next({ name: 'game' });
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("Routing Error", err);
|
info.clearUserInfo();
|
||||||
info.clearUserInfo();
|
next('/login');
|
||||||
next('/login');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ type TieInfo = {
|
|||||||
tiedPlayers: Player[]
|
tiedPlayers: Player[]
|
||||||
highestAmount: number
|
highestAmount: number
|
||||||
selectedCards: Record<string, Card>
|
selectedCards: Record<string, Card>
|
||||||
winners: Player[] | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TrumpInfo = {
|
type TrumpInfo = {
|
||||||
|
|||||||
@@ -25,16 +25,7 @@ ui.requestState().then(() => {
|
|||||||
router.replace("/")
|
router.replace("/")
|
||||||
} else {
|
} else {
|
||||||
ig.requestGame(ui.gameId).then(() => {
|
ig.requestGame(ui.gameId).then(() => {
|
||||||
// Attempt to connect to WebSocket
|
wb.connect()
|
||||||
wb.connect().catch((err) => {
|
|
||||||
console.error('[Game] Initial WebSocket connection failed:', err);
|
|
||||||
$q.notify({
|
|
||||||
message: 'Failed to connect to game server. Please try reconnecting.',
|
|
||||||
color: 'negative',
|
|
||||||
icon: 'error',
|
|
||||||
timeout: 5000
|
|
||||||
});
|
|
||||||
});
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,111 +1,59 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="login-container">
|
<div class="login-box q-col-gutter-sm">
|
||||||
<div class="login-box">
|
<div class="text-h3 text-center row">
|
||||||
<div class="logo-section">
|
<img src="/logo.png" alt="Logo" style="height: 60px; margin-right: 10px;" />
|
||||||
<div class="logo-container">
|
|
||||||
<img src="/logo.png" alt="Logo" class="logo" />
|
|
||||||
<div class="logo-text">KnockOut Whist</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-section">
|
|
||||||
<h1 class="title">Welcome Back</h1>
|
|
||||||
|
|
||||||
<q-form @submit.prevent="onSubmit" class="form-section">
|
|
||||||
<q-input
|
|
||||||
v-model="username"
|
|
||||||
label="Username"
|
|
||||||
filled
|
|
||||||
color="primary"
|
|
||||||
label-color="grey-6"
|
|
||||||
:error="!!loginError"
|
|
||||||
:error-message="loginError"
|
|
||||||
class="form-input"
|
|
||||||
lazy-rules
|
|
||||||
:rules="[ val => val && val.length > 0 || 'Username is required']"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon name="person" color="grey-6" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<q-input
|
|
||||||
v-model="password"
|
|
||||||
label="Password"
|
|
||||||
filled
|
|
||||||
type="password"
|
|
||||||
color="primary"
|
|
||||||
label-color="grey-6"
|
|
||||||
:error="!!loginError"
|
|
||||||
:error-message="loginError"
|
|
||||||
class="form-input"
|
|
||||||
lazy-rules
|
|
||||||
:rules="[
|
|
||||||
val => !!val || 'Password is required'
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon name="lock" color="grey-6" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<div class="action-buttons">
|
|
||||||
<q-btn
|
|
||||||
type="submit"
|
|
||||||
label="Sign In"
|
|
||||||
color="primary"
|
|
||||||
class="submit-btn"
|
|
||||||
:loading="inProgress"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</q-form>
|
|
||||||
|
|
||||||
<div class="divider-section">
|
|
||||||
<div class="divider">
|
|
||||||
<span class="divider-text">Or continue with</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="social-buttons">
|
|
||||||
<q-btn
|
|
||||||
@click="loginWithProvider('discord')"
|
|
||||||
class="social-btn discord-btn"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
icon="discord"
|
|
||||||
label="Discord"
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
@click="loginWithProvider('keycloak')"
|
|
||||||
class="social-btn keycloak-btn"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
icon="emoji_people"
|
|
||||||
label="Keycloak"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="register-link">
|
|
||||||
<span class="register-text">Don't have an account?</span>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
color="primary"
|
|
||||||
label="Register"
|
|
||||||
@click="goToRegister"
|
|
||||||
class="register-btn"
|
|
||||||
size="md"
|
|
||||||
dense
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<vue-particles
|
<q-form @submit.prevent="onSubmit"
|
||||||
id="particles-js"
|
class="q-gutter-md row justify-center"
|
||||||
:options='options'
|
style="width: 100%">
|
||||||
/>
|
|
||||||
|
<div class="row q-col-gutter-sm" style="width: 100%">
|
||||||
|
<q-input
|
||||||
|
style="width: 100%"
|
||||||
|
filled
|
||||||
|
dark
|
||||||
|
label-color="white"
|
||||||
|
color="white"
|
||||||
|
v-model="username"
|
||||||
|
label="Username *"
|
||||||
|
|
||||||
|
:error="!!loginError"
|
||||||
|
:error-message="loginError"
|
||||||
|
|
||||||
|
lazy-rules
|
||||||
|
:rules="[ val => val && val.length > 0 || 'Username is required']"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row q-col-gutter-sm" style="width: 100%">
|
||||||
|
<q-input
|
||||||
|
style="width: 100%"
|
||||||
|
filled
|
||||||
|
dark
|
||||||
|
type="password"
|
||||||
|
label-color="white"
|
||||||
|
color="white"
|
||||||
|
v-model="password"
|
||||||
|
label="Password *"
|
||||||
|
:error="!!loginError"
|
||||||
|
:error-message="loginError"
|
||||||
|
|
||||||
|
lazy-rules
|
||||||
|
:rules="[
|
||||||
|
val => !!val || 'Password is required'
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row justify-center">
|
||||||
|
<q-btn type="submit" label="Login" push color="dark" />
|
||||||
|
</div>
|
||||||
|
</q-form>
|
||||||
</div>
|
</div>
|
||||||
|
<vue-particles
|
||||||
|
id="particles-js"
|
||||||
|
:options='options'
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@@ -140,14 +88,6 @@ const onSubmit = () => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const loginWithProvider = (provider: string) => {
|
|
||||||
window.location.href = `${api}/auth/${provider}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const goToRegister = () => {
|
|
||||||
router.push('/register')
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
"particles": {
|
"particles": {
|
||||||
"number": {
|
"number": {
|
||||||
@@ -260,213 +200,19 @@ const options = {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.login-container {
|
.login-box {
|
||||||
position: relative;
|
position: fixed;
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
overflow: hidden;
|
top: 50%;
|
||||||
padding: 2rem;
|
left: 50%;
|
||||||
box-sizing: border-box;
|
transform: translate(-50%, -50%);
|
||||||
}
|
display: flex;
|
||||||
|
|
||||||
.login-box {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 420px;
|
max-width: 420px;
|
||||||
height: 100%;
|
padding: 1rem;
|
||||||
max-height: calc(100vh - 1rem);
|
|
||||||
background: var(--color-background-soft);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
border-radius: 24px;
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
border: 1px solid var(--color-border);
|
background-color: var(--color-background);
|
||||||
box-sizing: border-box;
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
|
||||||
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-section {
|
|
||||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
||||||
padding: 2rem;
|
|
||||||
text-align: center;
|
|
||||||
border-bottom: 1px solid var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
height: 50px;
|
|
||||||
width: auto;
|
|
||||||
filter: brightness(0) invert(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-text {
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-section {
|
|
||||||
padding: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
color: var(--color-heading);
|
|
||||||
font-size: 1.8rem;
|
|
||||||
font-weight: 700;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
color: var(--color-text);
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
line-height: 1.5;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1.5rem;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input {
|
|
||||||
border-radius: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
width: 100%;
|
|
||||||
height: 48px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider-section {
|
|
||||||
margin: 2rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider {
|
|
||||||
position: relative;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 1px;
|
|
||||||
background: var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider-text {
|
|
||||||
background: var(--color-background-soft);
|
|
||||||
padding: 0 1rem;
|
|
||||||
color: var(--color-text);
|
|
||||||
font-size: 0.85rem;
|
|
||||||
position: relative;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 1rem;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-btn {
|
|
||||||
flex: 1;
|
|
||||||
height: 48px;
|
|
||||||
background: var(--color-background-mute);
|
|
||||||
border: 2px solid var(--color-border);
|
|
||||||
color: var(--color-heading);
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-btn:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.discord-btn:hover {
|
|
||||||
border-color: #5865F2;
|
|
||||||
background: rgba(88, 101, 242, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.keycloak-btn:hover {
|
|
||||||
border-color: #0088CC;
|
|
||||||
background: rgba(0, 136, 204, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.register-link {
|
|
||||||
text-align: center;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.register-text {
|
|
||||||
color: var(--color-text);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.register-btn {
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#particles-js {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.login-box {
|
|
||||||
max-width: 100%;
|
|
||||||
border-radius: 16px;
|
|
||||||
max-height: calc(100vh - 1rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-section {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-buttons {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,516 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="register-container">
|
|
||||||
<div class="register-box">
|
|
||||||
<div class="logo-section">
|
|
||||||
<div class="logo-container">
|
|
||||||
<img src="/logo.png" alt="Logo" class="logo" />
|
|
||||||
<div class="logo-text">KnockOut Whist</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-section">
|
|
||||||
<h1 class="title">Create Account</h1>
|
|
||||||
<p class="subtitle">Join the ultimate card game experience</p>
|
|
||||||
|
|
||||||
<q-form @submit.prevent="onSubmit" class="form-section">
|
|
||||||
<q-input
|
|
||||||
v-model="username"
|
|
||||||
label="Username"
|
|
||||||
filled
|
|
||||||
color="primary"
|
|
||||||
label-color="grey-6"
|
|
||||||
:error="!!errorMessage"
|
|
||||||
:error-message="errorMessage"
|
|
||||||
class="form-input"
|
|
||||||
lazy-rules
|
|
||||||
:rules="[
|
|
||||||
val => !!val && val.trim().length > 0 || 'Username is required',
|
|
||||||
val => val && val.trim().length >= 3 || 'Username must be at least 3 characters',
|
|
||||||
val => val && val.trim().length <= 30 || 'Username must be less than 30 characters',
|
|
||||||
val => /^[a-zA-Z0-9_-]+$/.test(val) || 'Username can only contain letters, numbers, underscores, and hyphens'
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon name="person" color="grey-6" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<q-input
|
|
||||||
v-model="password"
|
|
||||||
label="Password"
|
|
||||||
filled
|
|
||||||
type="password"
|
|
||||||
color="primary"
|
|
||||||
label-color="grey-6"
|
|
||||||
:error="!!errorMessage"
|
|
||||||
:error-message="errorMessage"
|
|
||||||
class="form-input"
|
|
||||||
lazy-rules
|
|
||||||
:rules="[
|
|
||||||
val => !!val || 'Password is required',
|
|
||||||
val => val && val.length >= 6 || 'Password must be at least 6 characters'
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon name="lock" color="grey-6" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<q-input
|
|
||||||
v-model="confirmPassword"
|
|
||||||
label="Confirm Password"
|
|
||||||
filled
|
|
||||||
type="password"
|
|
||||||
color="primary"
|
|
||||||
label-color="grey-6"
|
|
||||||
:error="!!errorMessage"
|
|
||||||
:error-message="errorMessage"
|
|
||||||
class="form-input"
|
|
||||||
lazy-rules
|
|
||||||
:rules="[
|
|
||||||
val => !!val || 'Password confirmation is required',
|
|
||||||
val => val === password || 'Passwords do not match'
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon name="lock_outline" color="grey-6" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<div class="action-buttons">
|
|
||||||
<q-btn
|
|
||||||
type="submit"
|
|
||||||
label="Create Account"
|
|
||||||
color="primary"
|
|
||||||
class="submit-btn"
|
|
||||||
:loading="inProgress"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</q-form>
|
|
||||||
|
|
||||||
<div class="divider-section">
|
|
||||||
<div class="divider">
|
|
||||||
<span class="divider-text">Or register with</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="social-buttons">
|
|
||||||
<q-btn
|
|
||||||
@click="loginWithProvider('discord')"
|
|
||||||
class="social-btn discord-btn"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
icon="discord"
|
|
||||||
label="Discord"
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
@click="loginWithProvider('keycloak')"
|
|
||||||
class="social-btn keycloak-btn"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
icon="emoji_people"
|
|
||||||
label="Keycloak"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="login-link">
|
|
||||||
<span class="login-text">Already have an account?</span>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
color="primary"
|
|
||||||
label="Login"
|
|
||||||
@click="goToLogin"
|
|
||||||
class="login-btn"
|
|
||||||
size="md"
|
|
||||||
dense
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<vue-particles
|
|
||||||
id="particles-js"
|
|
||||||
:options='options'
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { useQuasar } from 'quasar'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import axios from "axios"
|
|
||||||
import router from "@/router"
|
|
||||||
|
|
||||||
const api = window?.__RUNTIME_CONFIG__?.API_URL
|
|
||||||
const $q = useQuasar()
|
|
||||||
|
|
||||||
const username = ref('')
|
|
||||||
const password = ref('')
|
|
||||||
const confirmPassword = ref('')
|
|
||||||
const inProgress = ref(false)
|
|
||||||
const errorMessage = ref('')
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
|
||||||
if (inProgress.value) return
|
|
||||||
|
|
||||||
inProgress.value = true
|
|
||||||
errorMessage.value = ''
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await axios.post(`${api}/register`, {
|
|
||||||
username: username.value.trim(),
|
|
||||||
password: password.value
|
|
||||||
})
|
|
||||||
|
|
||||||
if (response.status === 201) {
|
|
||||||
$q.notify({
|
|
||||||
type: 'positive',
|
|
||||||
message: 'Registration successful! Please login.',
|
|
||||||
position: 'top'
|
|
||||||
})
|
|
||||||
router.push('/login')
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error.response?.status === 409) {
|
|
||||||
errorMessage.value = 'Username already taken'
|
|
||||||
} else if (error.response?.status === 400) {
|
|
||||||
errorMessage.value = error.response.data?.message || 'Invalid input'
|
|
||||||
} else {
|
|
||||||
errorMessage.value = 'Registration failed. Please try again.'
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
inProgress.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const goToLogin = () => {
|
|
||||||
router.push('/login')
|
|
||||||
}
|
|
||||||
|
|
||||||
const loginWithProvider = (provider: string) => {
|
|
||||||
window.location.href = `${api}/auth/${provider}`
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
"particles": {
|
|
||||||
"number": {
|
|
||||||
"value": 80,
|
|
||||||
"density": {
|
|
||||||
"enable": true,
|
|
||||||
"area": 800
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color": {
|
|
||||||
"value": "#ffffff"
|
|
||||||
},
|
|
||||||
"shape": {
|
|
||||||
"type": "circle",
|
|
||||||
"stroke": {
|
|
||||||
"width": 0,
|
|
||||||
"color": "#000000"
|
|
||||||
},
|
|
||||||
"polygon": {
|
|
||||||
"sides": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"opacity": {
|
|
||||||
"value": 0.5,
|
|
||||||
"random": false,
|
|
||||||
"animation": {
|
|
||||||
"enable": false,
|
|
||||||
"speed": 1,
|
|
||||||
"minimumValue": 0.1,
|
|
||||||
"sync": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
"value": 3,
|
|
||||||
"random": true,
|
|
||||||
"animation": {
|
|
||||||
"enable": false,
|
|
||||||
"speed": 40,
|
|
||||||
"minimumValue": 0.1,
|
|
||||||
"sync": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"links": {
|
|
||||||
"enable": true,
|
|
||||||
"distance": 150,
|
|
||||||
"color": "#ffffff",
|
|
||||||
"opacity": 0.4,
|
|
||||||
"width": 1
|
|
||||||
},
|
|
||||||
"move": {
|
|
||||||
"enable": true,
|
|
||||||
"speed": 1,
|
|
||||||
"direction": "none",
|
|
||||||
"random": false,
|
|
||||||
"straight": false,
|
|
||||||
"outModes": {
|
|
||||||
"default": "out"
|
|
||||||
},
|
|
||||||
"attract": {
|
|
||||||
"enable": false,
|
|
||||||
"rotate": {
|
|
||||||
"x": 600,
|
|
||||||
"y": 1200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"interactivity": {
|
|
||||||
"detectsOn": "canvas",
|
|
||||||
"events": {
|
|
||||||
"onHover": {
|
|
||||||
"enable": false,
|
|
||||||
"mode": "repulse"
|
|
||||||
},
|
|
||||||
"onClick": {
|
|
||||||
"enable": false,
|
|
||||||
"mode": "push"
|
|
||||||
},
|
|
||||||
"resize": true
|
|
||||||
},
|
|
||||||
"modes": {
|
|
||||||
"grab": {
|
|
||||||
"distance": 400,
|
|
||||||
"links": {
|
|
||||||
"opacity": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bubble": {
|
|
||||||
"distance": 400,
|
|
||||||
"size": 40,
|
|
||||||
"duration": 2,
|
|
||||||
"opacity": 8,
|
|
||||||
"speed": 3
|
|
||||||
},
|
|
||||||
"repulse": {
|
|
||||||
"distance": 200,
|
|
||||||
"duration": 0.4
|
|
||||||
},
|
|
||||||
"push": {
|
|
||||||
"quantity": 4
|
|
||||||
},
|
|
||||||
"remove": {
|
|
||||||
"quantity": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"detectRetina": true
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.register-container {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 1rem;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.register-box {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 420px;
|
|
||||||
max-height: calc(100vh - 1rem);
|
|
||||||
background: var(--color-background-soft);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
border-radius: 24px;
|
|
||||||
box-shadow: 0 2px 2px rgba(0, 0, 0, 0.5);
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
z-index: 2;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-section {
|
|
||||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
||||||
padding: 2rem;
|
|
||||||
text-align: center;
|
|
||||||
border-bottom: 1px solid var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
height: 50px;
|
|
||||||
width: auto;
|
|
||||||
filter: brightness(0) invert(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-text {
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-section {
|
|
||||||
padding: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
color: var(--color-heading);
|
|
||||||
font-size: 1.8rem;
|
|
||||||
font-weight: 700;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
color: var(--color-text);
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
line-height: 1.5;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-input {
|
|
||||||
border-radius: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
width: 100%;
|
|
||||||
height: 48px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider-section {
|
|
||||||
margin: 2rem 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider {
|
|
||||||
position: relative;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
height: 1px;
|
|
||||||
background: var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.divider-text {
|
|
||||||
background: var(--color-background-soft);
|
|
||||||
padding: 0 1rem;
|
|
||||||
color: var(--color-text);
|
|
||||||
font-size: 0.85rem;
|
|
||||||
position: relative;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 1rem;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-btn {
|
|
||||||
flex: 1;
|
|
||||||
height: 48px;
|
|
||||||
background: var(--color-background-mute);
|
|
||||||
border: 2px solid var(--color-border);
|
|
||||||
color: var(--color-heading);
|
|
||||||
font-weight: 500;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-btn:hover {
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
.discord-btn:hover {
|
|
||||||
border-color: #5865F2;
|
|
||||||
background: rgba(88, 101, 242, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.keycloak-btn:hover {
|
|
||||||
border-color: #0088CC;
|
|
||||||
background: rgba(0, 136, 204, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-icon {
|
|
||||||
margin-right: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-text {
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-link {
|
|
||||||
text-align: center;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-text {
|
|
||||||
color: var(--color-text);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
#particles-js {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.register-box {
|
|
||||||
max-width: 100%;
|
|
||||||
border-radius: 16px;
|
|
||||||
max-height: calc(100vh - 1rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-section {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.social-buttons {
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,457 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="username-selection-container">
|
|
||||||
<div class="username-selection-box">
|
|
||||||
<div class="logo-section">
|
|
||||||
<div class="logo-container">
|
|
||||||
<img src="/logo.png" alt="Logo" class="logo" />
|
|
||||||
<div class="logo-text">KnockOut Whist</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="content-section">
|
|
||||||
<h1 class="title">Choose Your Username</h1>
|
|
||||||
<p class="subtitle">
|
|
||||||
You're signed in with <span class="provider-badge">{{ userInfo.providerName }}</span>. Please choose a username for your account.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="user-info-card">
|
|
||||||
<div class="user-avatar">
|
|
||||||
<img v-if="userInfo.picture" :src="userInfo.picture" alt="Profile" class="avatar-img" />
|
|
||||||
<div v-else class="avatar-text">{{ userInfo.name?.charAt(0)?.toUpperCase() || 'U' }}</div>
|
|
||||||
</div>
|
|
||||||
<div class="user-details">
|
|
||||||
<div class="user-name">{{ userInfo.name || 'Unknown User' }}</div>
|
|
||||||
<div class="user-provider">Signed in with {{ userInfo.providerName }}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<q-form @submit.prevent="onSubmit" class="form-section">
|
|
||||||
<q-input
|
|
||||||
v-model="username"
|
|
||||||
label="Username"
|
|
||||||
filled
|
|
||||||
dark
|
|
||||||
color="primary"
|
|
||||||
label-color="grey-6"
|
|
||||||
:error="!!errorMessage"
|
|
||||||
:error-message="errorMessage"
|
|
||||||
:loading="inProgress"
|
|
||||||
class="username-input"
|
|
||||||
lazy-rules
|
|
||||||
:rules="[
|
|
||||||
val => !!val && val.trim().length > 0 || 'Username is required',
|
|
||||||
val => val && val.trim().length >= 3 || 'Username must be at least 3 characters',
|
|
||||||
val => val && val.trim().length <= 30 || 'Username must be less than 30 characters',
|
|
||||||
val => /^[a-zA-Z0-9_-]+$/.test(val) || 'Username can only contain letters, numbers, underscores, and hyphens'
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<q-icon name="person" color="grey-6" />
|
|
||||||
</template>
|
|
||||||
</q-input>
|
|
||||||
|
|
||||||
<div class="action-buttons">
|
|
||||||
<q-btn
|
|
||||||
type="submit"
|
|
||||||
label="Complete Registration"
|
|
||||||
color="primary"
|
|
||||||
class="submit-btn"
|
|
||||||
:loading="inProgress"
|
|
||||||
size="md"
|
|
||||||
rounded
|
|
||||||
/>
|
|
||||||
<q-btn
|
|
||||||
flat
|
|
||||||
color="grey-6"
|
|
||||||
label="Cancel"
|
|
||||||
@click="goToLogin"
|
|
||||||
class="cancel-btn"
|
|
||||||
size="md"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</q-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<vue-particles
|
|
||||||
id="particles-js"
|
|
||||||
:options='options'
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { useQuasar } from 'quasar'
|
|
||||||
import { ref, onMounted } from 'vue'
|
|
||||||
import axios from "axios"
|
|
||||||
import router from "@/router"
|
|
||||||
import { useUserInfo } from "@/composables/useUserInfo"
|
|
||||||
|
|
||||||
const api = window?.__RUNTIME_CONFIG__?.API_URL
|
|
||||||
const $q = useQuasar()
|
|
||||||
const uInfo = useUserInfo()
|
|
||||||
|
|
||||||
const username = ref('')
|
|
||||||
const inProgress = ref(false)
|
|
||||||
const errorMessage = ref('')
|
|
||||||
const userInfo = ref({
|
|
||||||
id: '',
|
|
||||||
email: '',
|
|
||||||
name: '',
|
|
||||||
picture: '',
|
|
||||||
provider: '',
|
|
||||||
providerName: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
// Get user info from session storage or API
|
|
||||||
try {
|
|
||||||
const response = await axios.get(`${api}/select-username`, { withCredentials: true })
|
|
||||||
userInfo.value = response.data
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Failed to get user info:', error)
|
|
||||||
router.push('/login')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const onSubmit = async () => {
|
|
||||||
if (inProgress.value) return
|
|
||||||
|
|
||||||
inProgress.value = true
|
|
||||||
errorMessage.value = ''
|
|
||||||
|
|
||||||
try {
|
|
||||||
const response = await axios.post(`${api}/submit-username`, {
|
|
||||||
username: username.value.trim()
|
|
||||||
}, { withCredentials: true })
|
|
||||||
|
|
||||||
if (response.status === 200) {
|
|
||||||
// User successfully created and logged in
|
|
||||||
await uInfo.requestState()
|
|
||||||
router.push('/')
|
|
||||||
}
|
|
||||||
} catch (error: any) {
|
|
||||||
if (error.response?.status === 409) {
|
|
||||||
errorMessage.value = 'Username already taken'
|
|
||||||
} else if (error.response?.status === 400) {
|
|
||||||
errorMessage.value = error.response.data?.message || 'Invalid username'
|
|
||||||
} else {
|
|
||||||
errorMessage.value = 'Registration failed. Please try again.'
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
inProgress.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const goToLogin = () => {
|
|
||||||
router.push('/login')
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
"particles": {
|
|
||||||
"number": {
|
|
||||||
"value": 80,
|
|
||||||
"density": {
|
|
||||||
"enable": true,
|
|
||||||
"area": 800
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"color": {
|
|
||||||
"value": "#ffffff"
|
|
||||||
},
|
|
||||||
"shape": {
|
|
||||||
"type": "circle",
|
|
||||||
"stroke": {
|
|
||||||
"width": 0,
|
|
||||||
"color": "#000000"
|
|
||||||
},
|
|
||||||
"polygon": {
|
|
||||||
"sides": 5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"opacity": {
|
|
||||||
"value": 0.5,
|
|
||||||
"random": false,
|
|
||||||
"animation": {
|
|
||||||
"enable": false,
|
|
||||||
"speed": 1,
|
|
||||||
"minimumValue": 0.1,
|
|
||||||
"sync": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"size": {
|
|
||||||
"value": 3,
|
|
||||||
"random": true,
|
|
||||||
"animation": {
|
|
||||||
"enable": false,
|
|
||||||
"speed": 40,
|
|
||||||
"minimumValue": 0.1,
|
|
||||||
"sync": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"links": {
|
|
||||||
"enable": true,
|
|
||||||
"distance": 150,
|
|
||||||
"color": "#ffffff",
|
|
||||||
"opacity": 0.4,
|
|
||||||
"width": 1
|
|
||||||
},
|
|
||||||
"move": {
|
|
||||||
"enable": true,
|
|
||||||
"speed": 1,
|
|
||||||
"direction": "none",
|
|
||||||
"random": false,
|
|
||||||
"straight": false,
|
|
||||||
"outModes": {
|
|
||||||
"default": "out"
|
|
||||||
},
|
|
||||||
"attract": {
|
|
||||||
"enable": false,
|
|
||||||
"rotate": {
|
|
||||||
"x": 600,
|
|
||||||
"y": 1200
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"interactivity": {
|
|
||||||
"detectsOn": "canvas",
|
|
||||||
"events": {
|
|
||||||
"onHover": {
|
|
||||||
"enable": false,
|
|
||||||
"mode": "repulse"
|
|
||||||
},
|
|
||||||
"onClick": {
|
|
||||||
"enable": false,
|
|
||||||
"mode": "push"
|
|
||||||
},
|
|
||||||
"resize": true
|
|
||||||
},
|
|
||||||
"modes": {
|
|
||||||
"grab": {
|
|
||||||
"distance": 400,
|
|
||||||
"links": {
|
|
||||||
"opacity": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"bubble": {
|
|
||||||
"distance": 400,
|
|
||||||
"size": 40,
|
|
||||||
"duration": 2,
|
|
||||||
"opacity": 8,
|
|
||||||
"speed": 3
|
|
||||||
},
|
|
||||||
"repulse": {
|
|
||||||
"distance": 200,
|
|
||||||
"duration": 0.4
|
|
||||||
},
|
|
||||||
"push": {
|
|
||||||
"quantity": 4
|
|
||||||
},
|
|
||||||
"remove": {
|
|
||||||
"quantity": 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"detectRetina": true
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.username-selection-container {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 3rem;
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.username-selection-box {
|
|
||||||
width: 100%;
|
|
||||||
max-width: 420px;
|
|
||||||
height: 100%;
|
|
||||||
max-height: calc(100vh - 1rem);
|
|
||||||
background: var(--color-background-soft);
|
|
||||||
backdrop-filter: blur(20px);
|
|
||||||
border-radius: 24px;
|
|
||||||
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.5);
|
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
z-index: 2;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-section {
|
|
||||||
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
||||||
padding: 2rem;
|
|
||||||
text-align: center;
|
|
||||||
border-bottom: 1px solid var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
height: 50px;
|
|
||||||
width: auto;
|
|
||||||
filter: brightness(0) invert(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo-text {
|
|
||||||
color: #ffffff;
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-section {
|
|
||||||
padding: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
color: var(--color-heading);
|
|
||||||
font-size: 1.8rem;
|
|
||||||
font-weight: 700;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
color: var(--color-text);
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
font-size: 0.95rem;
|
|
||||||
line-height: 1.5;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
.provider-badge {
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
padding: 0.2rem 0.6rem;
|
|
||||||
border-radius: 12px;
|
|
||||||
font-size: 0.85rem;
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-info-card {
|
|
||||||
background: var(--color-background-mute);
|
|
||||||
border-radius: 16px;
|
|
||||||
padding: 1.5rem;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 1rem;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-avatar {
|
|
||||||
width: 60px;
|
|
||||||
height: 60px;
|
|
||||||
border-radius: 50%;
|
|
||||||
overflow: hidden;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-img {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-text {
|
|
||||||
color: white;
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 1.4rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-details {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-name {
|
|
||||||
color: var(--color-heading);
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 1.1rem;
|
|
||||||
margin-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-provider {
|
|
||||||
color: var(--color-text);
|
|
||||||
font-size: 0.9rem;
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-section {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.username-input {
|
|
||||||
border-radius: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-buttons {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1rem;
|
|
||||||
margin-top: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.submit-btn {
|
|
||||||
width: 100%;
|
|
||||||
height: 48px;
|
|
||||||
font-weight: 600;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cancel-btn {
|
|
||||||
width: 100%;
|
|
||||||
height: 48px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--color-text);
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cancel-btn:hover {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#particles-js {
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 600px) {
|
|
||||||
.username-selection-box {
|
|
||||||
max-width: 100%;
|
|
||||||
border-radius: 16px;
|
|
||||||
max-height: calc(100vh - 1rem);
|
|
||||||
}
|
|
||||||
|
|
||||||
.content-section {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
MAJOR=0
|
MAJOR=0
|
||||||
MINOR=25
|
MINOR=22
|
||||||
PATCH=0
|
PATCH=0
|
||||||
|
|||||||
@@ -22,9 +22,6 @@ export default defineConfig({
|
|||||||
globPatterns: [
|
globPatterns: [
|
||||||
'**/*.{js,css,html,ico,png,svg,webmanifest}',
|
'**/*.{js,css,html,ico,png,svg,webmanifest}',
|
||||||
],
|
],
|
||||||
navigateFallbackDenylist: [
|
|
||||||
/^\/api/,
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
manifest: {
|
manifest: {
|
||||||
|
|||||||
Reference in New Issue
Block a user