add electron store

This commit is contained in:
riqo 2021-05-28 09:03:49 -05:00
commit cc2babdadc
15 changed files with 391 additions and 135 deletions

View file

@ -25,7 +25,7 @@
<!-- submit button; position: fixed -->
<button class="submitButton button" type="submit">Submit</button>
</form>
<!-- back to login button: position: fixed -->
@ -37,21 +37,32 @@
import { defineComponent, ref } from "vue";
import { useIpc } from "@/modules/ipc";
import { authRequest } from '@/modules/message';
import { useProfile } from '@/modules/auth';
export default defineComponent({
name: "Login",
setup() {
const { post } = useIpc();
const { post, invoke } = useIpc();
const { setProfile } = useProfile();
const usr = ref("");
const pwd = ref("");
// Submit login credentials to the backend.
const submitForm = () => {
console.log(`Submitting login form: ${usr.value}, ${pwd.value}`)
post("client-message", authRequest(false, usr.value, pwd.value))
const submitForm = async () => {
try {
const res = await invoke('user-login', JSON.stringify({
email: usr.value,
password: pwd.value
}));
setProfile(res);
} catch(e) {
}
// console.log(`Submitting login form: ${usr.value}, ${pwd.value}`)
// post("client-message", authRequest(false, usr.value, pwd.value))
}
return {

View file

@ -30,6 +30,7 @@
import { defineComponent, ref } from "vue";
import { useIpc } from "@/modules/ipc";
import { logoutRequest } from '@/modules/message';
import { useProfile } from "@/modules/auth"
export default defineComponent({
name: "Settings",
@ -37,7 +38,9 @@
setup() {
const toggleSettings = ref(false);
const { post } = useIpc();
const { post, invoke } = useIpc();
const { clearProfile } = useProfile();
// Listen for escape key to close settings.
const onEscape = (e: any) => {
@ -54,9 +57,17 @@
}
// We ask server to log us out.
const onLogout = () => {
console.log("Submitting logout request.")
post("client-message", logoutRequest())
const onLogout = async () => {
console.log("Submitting logout request.");
try {
clearProfile();
await invoke("user-logout", "");
} catch(e) {
console.log('error')
}
}
return {