From 8a5c875bc5f3950c60be5320ea0e906d43aad635 Mon Sep 17 00:00:00 2001 From: clonbg Date: Fri, 24 Feb 2023 13:32:01 +0100 Subject: [PATCH] login en pinia --- src/pages/IndexPage.vue | 31 ++------------------------- src/stores/lista.js | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 src/stores/lista.js diff --git a/src/pages/IndexPage.vue b/src/pages/IndexPage.vue index ff5d461..811263c 100644 --- a/src/pages/IndexPage.vue +++ b/src/pages/IndexPage.vue @@ -7,35 +7,8 @@ diff --git a/src/stores/lista.js b/src/stores/lista.js new file mode 100644 index 0000000..a5209d1 --- /dev/null +++ b/src/stores/lista.js @@ -0,0 +1,47 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; +import PocketBase from "pocketbase"; + +export const useListaStore = defineStore("lista", () => { + const pb = new PocketBase("https://pocketbase.clonbg.es"); + const authData = ref(""); + function login() { + authData.value = pb + .collection("users") + .authWithPassword("clonbg", "m4nu3lm4nu3l") + .then((r) => { + console.log("logueado"); + }) + .catch((e) => { + console.log("error"); + }); + } + return { pb, authData, login }; +}); + +/* +--- Pinia + +export const useListaStore = defineStore("lista", () => { + const counter = ref(3); + function increment() { + counter.value++; + } + function doubleCount() { + return counter.value * 2; + } + return { counter, increment, doubleCount }; +}); + + +--- vue + +listaStore.counter = 9; +console.log(listaStore.counter); +console.log(listaStore.doubleCount()); +console.log(listaStore.counter); +listaStore.increment(); +console.log(listaStore.counter); + + +*/