Dark mode fix first page loading

This commit is contained in:
Surya Paolo
2022-11-29 15:25:06 +01:00
parent 1ab75a58f4
commit d6f537473e
6 changed files with 30 additions and 18 deletions

View File

@@ -35,6 +35,8 @@ export default {
const site = computed(() => globalStore.site) const site = computed(() => globalStore.site)
const darkcookie = ref(false)
watch(() => finishLoading.value, (newval: boolean, oldval: boolean) => { watch(() => finishLoading.value, (newval: boolean, oldval: boolean) => {
// console.log('watch finished', newval) // console.log('watch finished', newval)
if (newval) { if (newval) {
@@ -44,6 +46,7 @@ export default {
}) })
const listaRoutingNoLogin = ['/vreg?', '/offline'] const listaRoutingNoLogin = ['/vreg?', '/offline']
function meta() { function meta() {
@@ -75,6 +78,8 @@ export default {
} }
function mounted() { function mounted() {
darkcookie.value = tools.getCookie('darkmode', false, false, false) === '-1'
scroll() scroll()
} }
@@ -130,6 +135,7 @@ export default {
return { return {
finishLoading, finishLoading,
darkcookie,
} }
}, },
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<!--<q-layout view="lHh Lpr lFf" class="shadow-2 rounded-borders">---> <!--<q-layout view="lHh Lpr lFf" class="shadow-2 rounded-borders">--->
<q-layout view="hHh LpR fFf" class="shadow-2 rounded-borders"> <q-layout view="hHh LpR fFf" :class="`shadow-2 rounded-borders ` + ((darkcookie && !finishLoading) ? `bg-black`: ``)">
<app-header></app-header> <app-header></app-header>
<q-ajax-bar></q-ajax-bar> <q-ajax-bar></q-ajax-bar>
@@ -10,7 +10,7 @@
<app-footer></app-footer> <app-footer></app-footer>
<q-page-container id="mypage"> <q-page-container id="mypage" :class="(darkcookie && !finishLoading) ? `bg-black`: ``">
<div v-if="finishLoading"> <div v-if="finishLoading">
<CFirstPageApp></CFirstPageApp> <CFirstPageApp></CFirstPageApp>
<router-view/> <router-view/>

View File

@@ -1332,6 +1332,10 @@ export const shared_consts = {
value: 160, value: 160,
label: 'Stato Registrati', label: 'Stato Registrati',
}, },
{
value: 170,
label: 'CheckIfIsLogged',
},
{ {
value: 180, value: 180,
label: 'Info Versione', label: 'Info Versione',

View File

@@ -457,6 +457,13 @@
color="blue" color="blue"
type="a" type="a"
size="md" size="md"
:class="
myel.class +
(editOn ? ` clEdit` : ``) +
getClass() +
` ` +
tools.getClassAnim(myel.anim)
"
rounded rounded
:label="$t('reg.link_reg_and_msg')" :label="$t('reg.link_reg_and_msg')"
@click=" @click="

View File

@@ -26,7 +26,7 @@
<div class="q-gutter-xs testo-banda clgutter"> <div class="q-gutter-xs testo-banda clgutter">
<div class="text-h1"><span :class="`myshadow text-blue-9`">{{ t('msg.myAppName') }}</span></div> <div class="text-h1"><span :class="`myshadow text-blue-9`">{{ t('msg.myAppName') }}</span></div>
<div class="text-subtitle1 text-italic q-pl-sm"> <div class="text-subtitle1 text-italic q-pl-sm">
<span :class="`shadow text-black `">{{ t('msg.sottoTitoloApp') }}</span> <span :class="`shadow ` + $q.dark.isActive ? `text-white`: `text-black`">{{ t('msg.sottoTitoloApp') }}</span>
</div> </div>
<div> <div>
<div v-if="!tools.isLogged()" style="margin: 5px; padding: 5px" class="home"> <div v-if="!tools.isLogged()" style="margin: 5px; padding: 5px" class="home">
@@ -179,23 +179,11 @@
class="btn-start"> class="btn-start">
{{ $t('login.enter') }} {{ $t('login.enter') }}
</q-btn> </q-btn>
<!--<q-btn
rounded size="lg" color="positive" @click="PagReg"
class="btn-start">
{{ t('reg.submit') }}
</q-btn>-->
</div> </div>
</div> </div>
<div v-if="tools.isLogged()"> <div v-if="tools.isLogged()">
<div> <div>
<!--<q-field-->
<!--v-if="getPermission() === 'granted'"-->
<!--icon="notifications"-->
<!--class="shadow"-->
<!--:label="t('notification.titlegranted')"-->
<!--:helper="t('notification.statusnot')">-->
<!--</q-field>-->
<q-field <q-field
v-if="NotServiceWorker()" v-if="NotServiceWorker()"
class="shadow" class="shadow"

View File

@@ -86,14 +86,19 @@ export default defineComponent({
}) })
watch(() => dark.value, (value: any, oldval: any) => { watch(() => dark.value, (value: any, oldval: any) => {
$q.dark.set(value) if (isfinishLoading.value) {
tools.setCookie('darkmode', value ? '-1' : '0') $q.dark.set(value)
tools.setCookie('darkmode', value ? '-1' : '0')
}
}) })
function uploadStart() { function setDarkMode() {
dark.value = tools.getCookie('darkmode', false, false, false) === '-1' dark.value = tools.getCookie('darkmode', false, false, false) === '-1'
$q.dark.set(dark.value) $q.dark.set(dark.value)
}
function uploadStart() {
BeforeMount() BeforeMount()
} }
@@ -389,6 +394,8 @@ export default defineComponent({
} }
function BeforeMount() { function BeforeMount() {
setDarkMode()
// Estrai la Lang dal Localstorage // Estrai la Lang dal Localstorage
if (!globalStore.finishLoading) if (!globalStore.finishLoading)
return; return;