1
0
forked from noxious/client

haha keyboard go brrr

This commit is contained in:
2024-05-16 00:26:25 +02:00
parent 2638d6024f
commit 1ed0283a94
8 changed files with 154 additions and 153 deletions

View File

@ -1,5 +1,5 @@
<template>
<!-- <audio ref="bgm" id="bgm" src="/assets/music/bgm.mp3" loop autoplay></audio>-->
<audio ref="bgm" id="bgm" src="/assets/music/bgm.mp3" loop autoplay></audio>
<img src="/assets/bglogin.png" id="bg-img" alt="New Quest login background" />
<div class="content-wrapper">
<h1 class="main-title">NEW QUEST</h1>
@ -18,10 +18,10 @@
</form>
</div>
<div class="row-buttons">
<button class="button" @click="login">
<button class="button" @click="loginFunc">
<span>LOGIN</span>
</button>
<button class="button" @click="register">
<button class="button" @click="registerFunc">
<span>REGISTER</span>
</button>
<button class="button">
@ -33,27 +33,21 @@
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useSocketStore } from '@/stores/socket'
import { onMounted, ref } from 'vue'
import { useSocketStore } from '@/stores/socket.ts'
import {login, register} from '@/services/authService'
const bgm = ref('bgm');
if (bgm.value.paused) {
window.addEventListener('click', () => bgm.value.play())
window.addEventListener('keydown', () => bgm.value.play())
}
const socket = useSocketStore();
// const bgm = ref('bgm');
// const bgmStart = () => bgm.value.play();
// onMounted(() => {
// // check if bgm is playing already and do nothing
// if (bgm.value.paused) {
// window.addEventListener('click', () => bgm.value.play())
// window.addEventListener('keydown', () => bgm.value.play())
// }
//
// })
const username = ref('');
const password = ref('');
async function login() {
async function loginFunc() {
// check if username and password are valid
if (username.value === '' || password.value === '') {
alert('Please enter a valid username and password');
@ -61,13 +55,13 @@ async function login() {
}
// send register event to server
const success = await socket.login(username.value, password.value);
const success = await login(username.value, password.value);
if (!success) {
alert('Invalid username or password');
}
}
async function register() {
async function registerFunc() {
// check if username and password are valid
if (username.value === '' || password.value === '') {
alert('Please enter a valid username and password');
@ -75,14 +69,14 @@ async function register() {
}
// send register event to server
const success = await socket.register(username.value, password.value);
const success = await register(username.value, password.value);
if (!success) {
alert('Username already exists');
}
if (success) {
alert('User registered successfully');
alert('User registered successfully, you can now log in!');
}
}
</script>