From fd71f08430b94ed8ecb11b71a39c31423552f250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 30 Oct 2020 09:57:39 +0100 Subject: [PATCH] [Loading] Setze Standardeinstellungen --- quasar.conf.js | 2 +- src/boot/loading.ts | 10 ++++++++ src/plugins/user/store/user.ts | 47 +++++++++++++--------------------- src/store/index.ts | 8 +++--- 4 files changed, 32 insertions(+), 35 deletions(-) create mode 100644 src/boot/loading.ts diff --git a/quasar.conf.js b/quasar.conf.js index f503dd4..0074565 100644 --- a/quasar.conf.js +++ b/quasar.conf.js @@ -24,7 +24,7 @@ module.exports = configure(function(ctx) { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://quasar.dev/quasar-cli/boot-files - boot: ['composition-api', 'axios', 'login', 'plugins'], + boot: ['composition-api', 'axios', 'login', 'plugins', 'loading'], // https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css css: ['app.scss'], diff --git a/src/boot/loading.ts b/src/boot/loading.ts new file mode 100644 index 0000000..943f1ea --- /dev/null +++ b/src/boot/loading.ts @@ -0,0 +1,10 @@ +import { boot } from 'quasar/wrappers'; +import { Loading } from 'quasar'; + +// "async" is optional; +// more info on params: https://quasar.dev/quasar-cli/cli-documentation/boot-files#Anatomy-of-a-boot-file +export default boot(async (/* { app, router, Vue ... } */) => { + Loading.setDefaults({ + spinner: () => import('src/components/loading/DarkCircularProgress.vue') + }); +}); diff --git a/src/plugins/user/store/user.ts b/src/plugins/user/store/user.ts index c06a881..55b5044 100644 --- a/src/plugins/user/store/user.ts +++ b/src/plugins/user/store/user.ts @@ -16,20 +16,20 @@ export interface LoginResponse { } const empty_session: FG.Session = { - browser: '', - expires: new Date(), - lifetime: -1, - platform: '', - token: '' + browser: '', + expires: new Date(), + lifetime: -1, + platform: '', + token: '' }; const empty_user: FG.User = { - display_name: '', - firstname: '', - lastname: '', - mail: '', - roles: [], - userid: '' + display_name: '', + firstname: '', + lastname: '', + mail: '', + roles: [], + userid: '' }; const state: UserStateInterface = { @@ -56,9 +56,6 @@ const mutations: MutationTree = { const actions: ActionTree = { login({ commit }, data: LoginData) { commit('setLoginLoading', true); - Loading.setDefaults({ - spinner: () => import('src/components/loading/DarkCircularProgress.vue') - }); Loading.show({ message: 'Du wirst eingeloggt' }); @@ -83,7 +80,7 @@ const actions: ActionTree = { }); }, - doLogout({commit}, token: string) { + doLogout({ commit }, token: string) { Loading.show({ message: 'Du wirst ausgeloggt' }); void axios .delete(`/auth/${token}`) @@ -98,8 +95,10 @@ const actions: ActionTree = { }); }, - logout({ dispatch}, token: string) { - dispatch('doLogout', token).finally(() => {void Router.push({ name: 'login' });}); + logout({ dispatch }, token: string) { + dispatch('doLogout', token).finally(() => { + void Router.push({ name: 'login' }); + }); }, updateUser({ commit, state }, data) { @@ -117,19 +116,9 @@ const actions: ActionTree = { loadFromLocalStorage({ commit }) { console.log('load from store'); let data = LocalStorage.getItem('user'); - commit( - 'setUser', - data - ? data - : empty_user - ); + commit('setUser', data ? data : empty_user); data = LocalStorage.getItem('session'); - commit( - 'setSession', - data - ? data - : empty_session - ); + commit('setSession', data ? data : empty_session); commit('showState'); } }; diff --git a/src/store/index.ts b/src/store/index.ts index 70c972e..51e99bc 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,6 +1,5 @@ import { store } from 'quasar/wrappers'; import { SessionInterface } from 'src/plugins/user/store/session'; -import { UserStateInterface } from 'src/plugins/user/store/user'; import Vuex from 'vuex'; import { UserStateInterface } from 'src/plugins/user/store/user'; @@ -9,12 +8,11 @@ import { UserStateInterface } from 'src/plugins/user/store/user'; * directly export the Store instantiation */ export interface StateInterface { - user: UserStateInterface, - sessions: SessionInterface + user: UserStateInterface; + sessions: SessionInterface; } - -export default store(function ({ Vue }) { +export default store(function({ Vue }) { Vue.use(Vuex); const Store = new Vuex.Store({