180 lines
3.1 KiB
Vue
180 lines
3.1 KiB
Vue
<template>
|
|
<form id="login" @submit.prevent="submitForm">
|
|
|
|
|
|
<!-- login title -->
|
|
<div id="loginTitle">
|
|
<div>Login</div>
|
|
</div>
|
|
|
|
<!-- username and password forms -->
|
|
<div id="loginBox">
|
|
<!-- username -->
|
|
<div class="inputBox">
|
|
<input class="input" type="text" v-model="usr" />
|
|
<div class="inputModifier">Email</div>
|
|
</div>
|
|
|
|
|
|
<!-- password -->
|
|
<div class="inputBox">
|
|
<input class="input" type="password" v-model="pwd" />
|
|
<div class="inputModifier">Password</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- submit button; position: fixed -->
|
|
<button class="submitButton button" type="submit">Submit</button>
|
|
|
|
</form>
|
|
|
|
<!-- back to login button: position: fixed -->
|
|
<!-- <button class="createAccountButton button" @click.prevent="switchView">Create account</button> -->
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent, ref } from "vue";
|
|
import { setProfile } from '@/render/composables/useProfile';
|
|
import { invokeLogin } from "@/render/ipc";
|
|
|
|
export default defineComponent({
|
|
name: "Login",
|
|
|
|
setup() {
|
|
|
|
const usr = ref("");
|
|
const pwd = ref("");
|
|
|
|
// Submit login credentials to the backend.
|
|
const submitForm = async () => {
|
|
|
|
try {
|
|
|
|
const profile = await invokeLogin({
|
|
email: usr.value,
|
|
password: pwd.value
|
|
}) as Profile;
|
|
|
|
setProfile(profile)
|
|
|
|
|
|
} catch(e) {
|
|
console.log(e);
|
|
}
|
|
|
|
}
|
|
|
|
return {
|
|
usr,
|
|
pwd,
|
|
submitForm
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
#login {
|
|
width: 100vw;
|
|
height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
#loginTitle {
|
|
font-family: "SF Pro Text";
|
|
min-width: 181px;
|
|
font-size: 24px;
|
|
font-weight: bold;
|
|
text-align: left;
|
|
padding-bottom: 10px;
|
|
}
|
|
|
|
#loginBox {
|
|
font-family: "SF Compact Display";
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding-bottom: 20px;
|
|
}
|
|
|
|
.inputBox {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.input {
|
|
background-color: #B9B9B9;
|
|
border: none;
|
|
outline: none;
|
|
padding: 16px;
|
|
text-decoration: none;
|
|
margin: 4px 2px;
|
|
cursor: pointer;
|
|
border-radius: 10px;
|
|
}
|
|
|
|
.inputModifier {
|
|
min-width: 181px;
|
|
font-size: 12px;
|
|
font-weight: bold;
|
|
text-align: left;
|
|
margin-left: 15px;
|
|
}
|
|
|
|
.submitButton {
|
|
font-family: "SF Compact Display";
|
|
position: fixed;
|
|
margin-top: 141px;
|
|
background-color: #58C4FD;
|
|
color: white;
|
|
padding: 10px 30px;
|
|
border-radius: 20px;
|
|
font-size: 14px;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.submitButton:active {
|
|
background-color: #4296C3;
|
|
}
|
|
|
|
.createAccountButton {
|
|
position: absolute;
|
|
border: none;
|
|
background-color: #EBEBEB;
|
|
text-decoration: none;
|
|
color: #58C4FD;
|
|
font-weight: bold;
|
|
bottom: 20px;
|
|
right: 20px;
|
|
}
|
|
|
|
.button {
|
|
border: none;
|
|
outline: none;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.button:hover {
|
|
cursor: pointer;
|
|
}
|
|
|
|
.invalid {
|
|
margin-bottom: 30px;
|
|
font-family: "SF Compact Display";
|
|
font-weight: bold;
|
|
font-size: 14px;
|
|
color: #F53737;
|
|
}
|
|
|
|
</style>
|