67 lines
1.3 KiB
Vue
67 lines
1.3 KiB
Vue
<script setup lang="ts">
|
|
|
|
import goStore, { setReady, oauth2_register_discord, setup_websocket, heron_cookie_login } from "@/netcode";
|
|
|
|
await setup_websocket()
|
|
|
|
const heron_session = useCookie('heron_session')
|
|
const route = useRoute()
|
|
|
|
onMounted(async () => {
|
|
const code = route.query.code
|
|
if (!code) { return }
|
|
if (Array.isArray(code)) { return }
|
|
await setup_websocket()
|
|
oauth2_register_discord(code)
|
|
history.pushState(
|
|
{},
|
|
'',
|
|
'/'
|
|
)
|
|
})
|
|
|
|
|
|
onMounted(async () => {
|
|
if (!heron_session.value) { return }
|
|
heron_cookie_login(heron_session.value)
|
|
})
|
|
|
|
</script>
|
|
<template>
|
|
<div id="game_status">
|
|
|
|
<template v-if="goStore.self && !goStore.current_game?.started">
|
|
<input @change="setReady(($event.target as HTMLInputElement).checked)" type="checkbox" id="ready" />
|
|
<label for="ready">Ready</label>
|
|
</template>
|
|
</div>
|
|
<LoginView v-if="goStore.context === 'login'"></LoginView>
|
|
<GameBoard v-if="goStore.context != 'lobby' && goStore.context != 'login'"></GameBoard>
|
|
<LobbyView v-if="goStore.context == 'lobby'"></LobbyView>
|
|
</template>
|
|
|
|
<style>
|
|
html {
|
|
text-align: center;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
height: 100vh;
|
|
}
|
|
|
|
#__nuxt {
|
|
height: 100%;
|
|
user-select: none;
|
|
}
|
|
|
|
#game_status {
|
|
position: fixed;
|
|
z-index: 10;
|
|
top: 0;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
background-color: rgba(255, 255, 255, .75);
|
|
}
|
|
</style>
|