fix isAppRunning

This commit is contained in:
Surya Paolo
2022-12-20 10:58:55 +01:00
parent 3aaa94c33e
commit 2a97456c0f
17 changed files with 57 additions and 36 deletions

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.44" APP_VERSION="0.5.46"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL="newfreeplanet" DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.44" APP_VERSION="0.5.46"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.44" APP_VERSION="0.5.46"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL="newfreeplanet" DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.44" APP_VERSION="0.5.46"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="13" APP_ID="13"
DIRECTORY_LOCAL=newfreeplanet DIRECTORY_LOCAL=newfreeplanet

View File

@@ -1,4 +1,4 @@
APP_VERSION="0.5.44" APP_VERSION="0.5.46"
SERVICE_WORKER_FILE="service-worker.js" SERVICE_WORKER_FILE="service-worker.js"
APP_ID="14" APP_ID="14"
DIRECTORY_LOCAL="newfreeplanet" DIRECTORY_LOCAL="newfreeplanet"

View File

@@ -75,29 +75,14 @@ export default {
console.log('scrolled') console.log('scrolled')
} }
} }
let displayMode = 'browser';
const mqStandAlone = '(display-mode: standalone)';
if (navigator)
console.log('navigator')
// @ts-ignore
if (navigator && navigator.standalone)
console.log('navigator.standalone')
// @ts-ignore
if (((navigator && (navigator.standalone))) ||
(window.matchMedia(mqStandAlone).matches)) {
console.log('navigator.standalone')
displayMode = 'standalone'
}
globalStore.isAppRunning = displayMode === 'standalone';
console.log('isapp running = ', globalStore.isAppRunning)
} }
function mounted() { function mounted() {
darkcookie.value = tools.getCookie('darkmode', false, false, false) === '-1' darkcookie.value = tools.getCookie('darkmode', false, false, false) === '-1'
scroll() scroll()
tools.checkApp()
} }

View File

@@ -1,4 +1,4 @@
import { defineComponent, ref, computed, PropType, toRef } from 'vue' import { defineComponent, ref, computed, PropType, toRef, onMounted } from 'vue'
import { useUserStore } from '@store/UserStore' import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore' import { useGlobalStore } from '@store/globalStore'
@@ -19,36 +19,41 @@ export default defineComponent({
const globalStore = useGlobalStore() const globalStore = useGlobalStore()
const { t } = useI18n() const { t } = useI18n()
const deferredPrompt = ref(<any>null)
const isAppRunning = computed(() => globalStore.isAppRunning ) const isAppRunning = computed(() => globalStore.isAppRunning )
const finishLoading = computed(() => globalStore.finishLoading) const finishLoading = computed(() => globalStore.finishLoading)
const deferredPrompt = computed(() => globalStore.deferredPrompt)
function initprompt() { function initprompt() {
window.addEventListener('beforeinstallprompt', (event) => { window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault() event.preventDefault()
console.log('beforeinstallprompt !') console.log('beforeinstallprompt !')
// Stash the event so it can be triggered later. // Stash the event so it can be triggered later.
deferredPrompt.value = event globalStore.deferredPrompt = event
}) })
} }
function installApp() { function installApp() {
if (deferredPrompt.value) if (globalStore.deferredPrompt)
deferredPrompt.value.prompt() globalStore.deferredPrompt.prompt()
} }
initprompt() function mounted() {
initprompt()
tools.checkApp()
}
onMounted(mounted)
return { return {
userStore, userStore,
tools, tools,
costanti, costanti,
finishLoading, finishLoading,
deferredPrompt,
installApp, installApp,
isAppRunning, isAppRunning,
deferredPrompt,
} }
} }
}) })

View File

@@ -103,6 +103,8 @@ export default defineComponent({
userStore.signin($router, signin.value) userStore.signin($router, signin.value)
.then((riscode: any) => { .then((riscode: any) => {
console.log('signin FINITO CALL: riscode=', riscode) console.log('signin FINITO CALL: riscode=', riscode)
tools.checkApp()
if ($q.screen.lt.sm) { if ($q.screen.lt.sm) {
globalStore.setleftDrawerOpen(false) globalStore.setleftDrawerOpen(false)
} }

View File

@@ -87,6 +87,7 @@ export default defineComponent({
const isalreadyReg = ref(false) const isalreadyReg = ref(false)
const needTelegram = ref(false) const needTelegram = ref(false)
const slide = ref('1') const slide = ref('1')
const inputAportador = ref(<any>null)
const inputEmail = ref(<any>null) const inputEmail = ref(<any>null)
const inputUsername = ref(<any>null) const inputUsername = ref(<any>null)
const inputName = ref(<any>null) const inputName = ref(<any>null)
@@ -98,7 +99,7 @@ export default defineComponent({
let ret = true let ret = true
if (slide.value === '1') { if (slide.value === '1') {
// Invitante + Email // Invitante + Email
ret = !signup.email || !v$.value.aportador_solidario || v$.value.aportador_solidario.$invalid || (inputEmail.value && inputEmail.value.hasError) ret = !signup.email || !signup.aportador_solidario || inputAportador.value.hasError || (inputEmail.value && inputEmail.value.hasError)
} else if (slide.value === '2') { } else if (slide.value === '2') {
// Username // Username
ret = !signup.username || (inputUsername.value && inputUsername.value.hasError) ret = !signup.username || (inputUsername.value && inputUsername.value.hasError)
@@ -391,6 +392,7 @@ export default defineComponent({
needTelegram, needTelegram,
slide, slide,
checkifDisabled, checkifDisabled,
inputAportador,
inputEmail, inputEmail,
inputUsername, inputUsername,
inputName, inputName,

View File

@@ -113,6 +113,7 @@
showaportador && showaportador &&
signup.aportador_solidario !== tools.APORTADOR_NONE signup.aportador_solidario !== tools.APORTADOR_NONE
" "
ref="inputAportador"
bg-color="lightblue" bg-color="lightblue"
:readonly="!!ap_iniziale" :readonly="!!ap_iniziale"
v-model="signup.aportador_solidario" v-model="signup.aportador_solidario"

View File

@@ -156,6 +156,7 @@ export default defineComponent({
comune: 1, comune: 1,
userId: 1, userId: 1,
username: 1, username: 1,
name: 1,
surname: 1, surname: 1,
lasttimeonline: 1, lasttimeonline: 1,
mycities: 1, mycities: 1,

View File

@@ -34,7 +34,7 @@ export default function () {
function getTeacherByUsername(username: string) { function getTeacherByUsername(username: string) {
const op = getOperatorByUsername(username) const op = getOperatorByUsername(username)
if (!!op) { if (!!op) {
return op.name ? op.name : '' + ' ' + op.surname ? op.surname : '' return (op.name ? op.name : '') + ' ' + op.surname ? op.surname : ''
} else { } else {
return '' return ''
} }

View File

@@ -457,6 +457,7 @@ export interface IGlobalState {
myselector: ISelector, myselector: ISelector,
addNewRecord: string, addNewRecord: string,
isAppRunning: boolean isAppRunning: boolean
deferredPrompt: any
} }
export interface IMenuList { export interface IMenuList {

View File

@@ -7394,6 +7394,27 @@ export const tools = {
return myarr return myarr
}, },
checkApp() {
const globalStore = useGlobalStore()
try {
let displayMode = 'browser';
const mqStandAlone = '(display-mode: standalone)';
// @ts-ignore
if (((navigator && (navigator.standalone))) ||
(window.matchMedia(mqStandAlone).matches)) {
console.log('navigator.standalone')
displayMode = 'standalone'
}
console.log('displayMode = ', displayMode)
globalStore.isAppRunning = displayMode === 'standalone';
} catch (e) {
console.log('error navigator.standalone ?!')
}
},
// getLocale() { // getLocale() {
// if (navigator.languages && navigator.languages.length > 0) { // if (navigator.languages && navigator.languages.length > 0) {
// return navigator.languages[0] // return navigator.languages[0]

View File

@@ -449,12 +449,12 @@ export const useUserStore = defineStore('UserStore', {
let myrec = this.getRecByCol(user, col) let myrec = this.getRecByCol(user, col)
if (!!myrec.name) if (!!myrec.name)
name = myrec.name name = myrec.name + ' '
if (!!myrec.surname) if (!!myrec.surname)
name += ' ' + myrec.surname name += myrec.surname + ' '
if (!name) { if (!name) {
name = myrec.username name += myrec.username + ' '
} }
if (col && col.field === 'extrarec' && !name) { if (col && col.field === 'extrarec' && !name) {
name = myrec.dest name = myrec.dest
@@ -996,6 +996,8 @@ export const useUserStore = defineStore('UserStore', {
await globalStore.clearDataAfterLogout() await globalStore.clearDataAfterLogout()
tools.checkApp()
return Api.SendReq('/users/me/token', 'DELETE', null) return Api.SendReq('/users/me/token', 'DELETE', null)
.then((res) => { .then((res) => {
console.log(res) console.log(res)

View File

@@ -183,6 +183,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
myselector: { data: {}, table: ''}, myselector: { data: {}, table: ''},
addNewRecord: '', addNewRecord: '',
isAppRunning: false, isAppRunning: false,
deferredPrompt: null,
}), }),
getters: { getters: {

View File

@@ -46,7 +46,7 @@
<div v-if="site.confpages.showNameSurname"> <div v-if="site.confpages.showNameSurname">
<div class="text-h6"> <div class="text-h6">
<span v-if="checkifShow('name') && myuser.name"> {{ myuser.name }}</span> <span v-if="checkifShow('name') && myuser.name"> {{ myuser.name }}</span>
<span v-if="checkifShow('surname') && myuser.surname">{{ <span v-if="checkifShow('surname') && myuser.surname">&nbsp;{{
myuser.surname myuser.surname
}}</span> }}</span>
</div> </div>