doc: import ref, supabase, and store and set them up

This commit is contained in:
Leon Xu
2021-12-31 12:11:09 -08:00
parent 624c14caff
commit e99078b5c5
+14 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="min-h-full font-Poppins box-border">
<div v-if="appReady" class="min-h-full font-Poppins box-border">
<Navigation />
<router-view />
</div>
@@ -7,21 +7,32 @@
<script>
import Navigation from "./components/Navigation.vue";
import { ref } from "vue";
import { supabase } from "./supabase/init";
import store from "./store/index";
export default {
components: {
Navigation,
},
setup() {
// Create data / vars
const appReady = ref(null);
// Check to see if user is already logged in
const user = supabase.auth.user();
// If user does not exist, need to make app ready
if (!user) {
appReady.value = true;
}
// Runs when there is a auth state change
// if user is logged in, this will fire
return {};
supabase.auth.onAuthStateChange((_, session) => {
store.methods.setUser(session);
appReady.value = true;
});
return { appReady };
},
};
</script>