add splash screen on load

This commit is contained in:
riqo 2021-02-28 14:27:51 -06:00
commit 346bfcba01
9 changed files with 218 additions and 243 deletions

View file

@ -1,4 +1,4 @@
import { reactive, toRefs } from 'vue';
import { reactive, toRefs, ref } from 'vue';
import { useIpc } from './ipc';
interface AuthState {
@ -11,6 +11,8 @@ const state = reactive<AuthState>({
error: undefined,
});
const loading = ref(true);
const AUTH_KEY = 'crimata_token';
const token = window.localStorage.getItem(AUTH_KEY);
@ -20,6 +22,7 @@ if (token) {
}
const authToken = async () => {
loading.value = true;
const { invoke } = useIpc();
try {
const res = await invoke('auth-session', token);
@ -32,6 +35,7 @@ const authToken = async () => {
window.localStorage.removeItem(AUTH_KEY);
state.accessToken = null;
}
loading.value = false;
}
// authenticate on auth event
@ -56,5 +60,6 @@ export const useAuth = () => {
setToken,
logout,
...toRefs(state), // accessToken, error
loading
}
}