fix(ready): remove class form fragment
This commit is contained in:
parent
cdbd1c2ac4
commit
29d8422e94
6 changed files with 45 additions and 30 deletions
32
src/App.vue
32
src/App.vue
|
@ -1,32 +1,27 @@
|
||||||
<template>
|
<template>
|
||||||
<ready>
|
<ready>
|
||||||
<div :class="{'is-touch': isTouch}">
|
<template v-if="authUser">
|
||||||
<div :class="{'is-hidden': !online}">
|
<top-navigation/>
|
||||||
<template v-if="authUser">
|
<content-auth/>
|
||||||
<top-navigation/>
|
</template>
|
||||||
<content-auth/>
|
<content-link-share v-else-if="authLinkShare"/>
|
||||||
</template>
|
<no-auth-wrapper v-else>
|
||||||
<content-link-share v-else-if="authLinkShare"/>
|
<router-view/>
|
||||||
<no-auth-wrapper v-else>
|
</no-auth-wrapper>
|
||||||
<router-view/>
|
<Notification/>
|
||||||
</no-auth-wrapper>
|
|
||||||
<Notification/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<keyboard-shortcuts v-if="keyboardShortcutsActive"/>
|
<keyboard-shortcuts v-if="keyboardShortcutsActive"/>
|
||||||
</transition>
|
</transition>
|
||||||
</div>
|
|
||||||
</ready>
|
</ready>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import {computed, watch, watchEffect, Ref} from 'vue'
|
import {computed, watch, Ref} from 'vue'
|
||||||
import {useRouter} from 'vue-router'
|
import {useRouter} from 'vue-router'
|
||||||
import {useRouteQuery} from '@vueuse/router'
|
import {useRouteQuery} from '@vueuse/router'
|
||||||
import {useStore} from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
import {useI18n} from 'vue-i18n'
|
import {useI18n} from 'vue-i18n'
|
||||||
import {useOnline} from '@vueuse/core'
|
|
||||||
import isTouchDevice from 'is-touch-device'
|
import isTouchDevice from 'is-touch-device'
|
||||||
import {success} from '@/message'
|
import {success} from '@/message'
|
||||||
|
|
||||||
|
@ -40,17 +35,14 @@ import Ready from '@/components/misc/ready.vue'
|
||||||
|
|
||||||
import {setLanguage} from './i18n'
|
import {setLanguage} from './i18n'
|
||||||
import AccountDeleteService from '@/services/accountDelete'
|
import AccountDeleteService from '@/services/accountDelete'
|
||||||
import {ONLINE} from '@/store/mutation-types'
|
|
||||||
|
|
||||||
import {useColorScheme} from '@/composables/useColorScheme'
|
import {useColorScheme} from '@/composables/useColorScheme'
|
||||||
|
import {useBodyClass} from '@/composables/useBodyClass'
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const online = useOnline()
|
|
||||||
watchEffect(() => store.commit(ONLINE, online.value))
|
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const isTouch = computed(isTouchDevice)
|
useBodyClass('is-touch', isTouchDevice)
|
||||||
const keyboardShortcutsActive = computed(() => store.state.keyboardShortcutsActive)
|
const keyboardShortcutsActive = computed(() => store.state.keyboardShortcutsActive)
|
||||||
|
|
||||||
const authUser = computed(() => store.getters['auth/authUser'])
|
const authUser = computed(() => store.getters['auth/authUser'])
|
||||||
|
|
|
@ -50,11 +50,12 @@ import Message from '@/components/misc/message.vue'
|
||||||
import NoAuthWrapper from '@/components/misc/no-auth-wrapper.vue'
|
import NoAuthWrapper from '@/components/misc/no-auth-wrapper.vue'
|
||||||
|
|
||||||
import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
||||||
|
import {useOnline} from '@/composables/useOnline'
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
const ready = computed(() => store.state.vikunjaReady)
|
const ready = computed(() => store.state.vikunjaReady)
|
||||||
const online = computed(() => store.state.online)
|
const online = useOnline()
|
||||||
|
|
||||||
const error = ref('')
|
const error = ref('')
|
||||||
const showLoading = computed(() => !ready.value && error.value === '')
|
const showLoading = computed(() => !ready.value && error.value === '')
|
||||||
|
|
16
src/composables/useBodyClass.ts
Normal file
16
src/composables/useBodyClass.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import {ref, watchEffect} from 'vue'
|
||||||
|
import {tryOnBeforeUnmount} from '@vueuse/core'
|
||||||
|
|
||||||
|
export function useBodyClass(className: string, defaultValue = false) {
|
||||||
|
const isActive = ref(defaultValue)
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
isActive.value
|
||||||
|
? document.body.classList.add(className)
|
||||||
|
: document.body.classList.remove(className)
|
||||||
|
})
|
||||||
|
|
||||||
|
tryOnBeforeUnmount(() => isActive.value && document.body.classList.remove(className))
|
||||||
|
|
||||||
|
return isActive
|
||||||
|
}
|
14
src/composables/useOnline.ts
Normal file
14
src/composables/useOnline.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import {ref} from 'vue'
|
||||||
|
import {useOnline as useNetworkOnline, ConfigurableWindow} from '@vueuse/core'
|
||||||
|
|
||||||
|
|
||||||
|
export function useOnline(options?: ConfigurableWindow) {
|
||||||
|
const fakeOnlineState = !!import.meta.env.VITE_IS_ONLINE
|
||||||
|
if (fakeOnlineState) {
|
||||||
|
console.log('Setting fake online state', fakeOnlineState)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fakeOnlineState
|
||||||
|
? ref(true)
|
||||||
|
: useNetworkOnline(options)
|
||||||
|
}
|
|
@ -7,7 +7,7 @@ import {
|
||||||
LOADING,
|
LOADING,
|
||||||
LOADING_MODULE,
|
LOADING_MODULE,
|
||||||
MENU_ACTIVE,
|
MENU_ACTIVE,
|
||||||
ONLINE, QUICK_ACTIONS_ACTIVE,
|
QUICK_ACTIONS_ACTIVE,
|
||||||
} from './mutation-types'
|
} from './mutation-types'
|
||||||
import config from './modules/config'
|
import config from './modules/config'
|
||||||
import auth from './modules/auth'
|
import auth from './modules/auth'
|
||||||
|
@ -36,7 +36,6 @@ export const store = createStore({
|
||||||
state: {
|
state: {
|
||||||
loading: false,
|
loading: false,
|
||||||
loadingModule: null,
|
loadingModule: null,
|
||||||
online: true,
|
|
||||||
// This is used to highlight the current list in menu for all list related views
|
// This is used to highlight the current list in menu for all list related views
|
||||||
currentList: {id: 0},
|
currentList: {id: 0},
|
||||||
background: '',
|
background: '',
|
||||||
|
@ -53,12 +52,6 @@ export const store = createStore({
|
||||||
[LOADING_MODULE](state, module) {
|
[LOADING_MODULE](state, module) {
|
||||||
state.loadingModule = module
|
state.loadingModule = module
|
||||||
},
|
},
|
||||||
[ONLINE](state, online) {
|
|
||||||
if (import.meta.env.VITE_IS_ONLINE) {
|
|
||||||
console.log('Setting fake online state', import.meta.env.VITE_IS_ONLINE)
|
|
||||||
}
|
|
||||||
state.online = !!import.meta.env.VITE_IS_ONLINE || online
|
|
||||||
},
|
|
||||||
[CURRENT_LIST](state, currentList) {
|
[CURRENT_LIST](state, currentList) {
|
||||||
// Server updates don't return the right. Therefore the right is reset after updating the list which is
|
// Server updates don't return the right. Therefore the right is reset after updating the list which is
|
||||||
// confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right
|
// confusing because all the buttons will disappear in that case. To prevent this, we're keeping the right
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
export const LOADING = 'loading'
|
export const LOADING = 'loading'
|
||||||
export const LOADING_MODULE = 'loadingModule'
|
export const LOADING_MODULE = 'loadingModule'
|
||||||
export const ONLINE = 'online'
|
|
||||||
export const CURRENT_LIST = 'currentList'
|
export const CURRENT_LIST = 'currentList'
|
||||||
export const HAS_TASKS = 'hasTasks'
|
export const HAS_TASKS = 'hasTasks'
|
||||||
export const MENU_ACTIVE = 'menuActive'
|
export const MENU_ACTIVE = 'menuActive'
|
||||||
|
|
Loading…
Reference in a new issue